Advertisement
amberweinberg

Count ACF Repeater Rows, add closing syntax to even/odd

Jun 7th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.                    
  3.     $d=1; if( have_rows('testimonials') ): while ( have_rows('testimonials') ) : the_row();
  4.    
  5.     $rows = get_field('testimonials');
  6.     $row_count = count($rows);
  7.    
  8.     if($d==1) echo '<div class="col-sm-6"><ul class="tstLst">';
  9. ?>
  10.            
  11.         <li>
  12.             <?php the_sub_field('testimonial_content'); ?>
  13.             <b class="author">- <?php the_sub_field('testimonial_author'); ?></b>
  14.         </li>
  15.        
  16.     <?php if($d==2) echo '</ul></div>'; ?>
  17.  
  18. <?php if($d==2) $d=1; else $d++; endwhile; if( $row_count & 1 ) echo '</ul></div>'; endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement