Need help? Check out our Support site, then


Problem with columns and custom fields/truncate function

  1. I'm set up twenty eleven as a child theme and created a custom page with advanced custom fields. I created a page with 2 columns and everything works great until I used truncated text.

    function trunc($phrase, $max_words)<br /> {<br /> $phrase_array = explode(' ',$phrase);<br /> if(count($phrase_array) > $max_words && $max_words > 0)<br /> $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'...'<br /> return $phrase;<br /> }</p> <p>I used this code in my functions.php and it's working as supposed to be. However, I'm experiencing a problem with my page when using this function in columns. As long as I am using the get_field alone without trunc, the columns look OK but as soon as I'm using trunc, I have a problem with the first column, second row moving over to the second column. You can check it here: http://tierhilfe-spanien.org/zuhause-gesucht/huendinnen/</p> <p>Here's the code I'm using in my template file:<br /> <?php /*<br /> Template Name: Huendinnen<br /> */</p> <p>get_header(); ?></p> <p><div id="content" role="main"><br /> <div id="primary"></p> <p> <?php while ( have_posts() ) : the_post(); ?></p> <p> <?php get_template_part( 'content', 'page' ); ?></p> <p> <?php comments_template( '', true ); ?></p> <p> <?php endwhile; // end of the loop. ?></p> <p><?php<br /> $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;<br /> $args= array(<br /> 'category_name' => 'Huendinnen', // Change these category SLUGS to suit your use.<br /> 'paged' => $paged<br /> );<br /> query_posts($args);<br /> if( have_posts() ) :?></p> <p><div id="column-wrap"><br /> <?php $count = 0;</p> <p>while(have_posts()) : the_post(); ?></p> <p><div class="box<?php if( $count%2 == 0 ) { echo '-1'; }; $count++; ?>"></p> <p><?php if(get_field('name_des_tieres')) { ?><br /> <h1><strong> <?php the_field('name_des_tieres'); ?></strong></h1><br /> <?php } ?></p> <p><?php if(get_field('ort') == "Spanien"): ?><br /> <div class="floatright"><br />  <br /> <img src="http://tierhilfe-spanien.org/wp-content/uploads/2012/01/Spain.gif" alt="Spanien" height="25" width="35" /><br /> </div><br /> <?php endif; ?></p> <p><?php if(get_field('ort') == "Deutschland"): ?><br /> <div class="floatright"><br />  <br /> <img src="http://tierhilfe-spanien.org/wp-content/uploads/2012/01/Germany.gif" alt="Deutschland" height="25" width="35" /><br /> </div><br /> <?php endif; ?></p> <p><?php<br /> if(get_field('notfall')): ?><br /> <div class="floatright"><br /> <img src="http://tierhilfe-spanien.org/wp-content/uploads/2012/01/Notfall.gif" alt="Notfall" height="25" width="75" /><br /> </div><br /> <?php endif; ?></p> <p><?php<br /> if(get_field('reserviert')): ?><br /> <div class="floatright"><br /> <img src="http://tierhilfe-spanien.org/wp-content/uploads/Reserviert.gif" alt="Reserviert" height="25" width="75" /><br /> </div><br /> <?php endif; ?></p> <p><?php<br /> if(get_field('pate_gesucht')): ?><br /> <div class="floatright"><br /> <img src="http://tierhilfe-spanien.org/wp-content/uploads/Pate-gesucht.gif" alt="Pate gesucht" height="25" width="75" /><br /> </div><br /> <?php endif; ?></p> <p><div class="animalinfo"><br /> <strong>Geboren</strong>: <br /> <?php if(get_field('geburtsdatum')) { ?><br /> <?php the_field('geburtsdatum'); ?><br /> <?php } ?><br /> </div></p> <p><div class="animalinfo"><br /> <strong>Größe</strong>:    <br /> <?php if(get_field('groesse')) { ?><br /> <?php the_field('groesse'); ?><br /> <?php } ?><br /> </div><br /> <p></p></p> <p><?php if(get_field('bild_1')): ?><br /> <a>"><img class="alignleft featured_image" width="100" src="<?php the_field('bild_1'); ?>" /></a><br /> <?php endif; ?></p> <p><span style="font-size: x-small;"><br /> <p style="text-align: right;"></p> <p><span style="font-size: small;"><?php echo trunc(get_field('beschreibung'),22); ?><br /> <p style="text-align: right;"><br /> <?php echo '<a><br /> <?php the_permalink(); ?><br /> <?php echo '"title="weiter lesen">mehr...</a>'; ?><br /> </p></span></p> <p></div></p> <p><?php endwhile; ?><br /> </div><!--end column-wrap--></p> <p><?php twentyeleven_content_nav( 'nav-below' ); ?></p> <p><?php else : ?><br /> <article id="post-0" class="post no-results not-found"><br /> <header class="entry-header"><br /> <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1><br /> </header><!-- .entry-header --></p> <p><div class="entry-content"><br /> <p><?php _e( 'Für dieses Archiv wurden keine Artikel gefunden. Vielleicht kann Ihnen die Suchfunktion behilflich sein.', 'twentyeleven' ); ?></p><br /> <?php get_search_form(); ?><br /> </div><br /> </article></p> <p><?php endif; ?></p> <p></div><br /> </div><br /> <?php get_footer();

  2. thesacredpath
    Staff

    Sorry, you are in the wrong forum. You need to head over to the WordPress.org forums as that is where self-hosted wordpress blogs using the software from wordpress.ORG are supported.

    These forums are for those hosted here on the wordpress.COM free hosting service and things here work differently.

    If you are not familiar with the differences, see this support document.

  3. Sry & thx.

  4. thesacredpath
    Staff

    Not a problem and good luck.

Topic Closed

This topic has been closed to new replies.

About this Topic