Support

Account

Home Forums Add-ons Repeater Field Is there a way to separate repeater rows by groups of five? Reply To: Is there a way to separate repeater rows by groups of five?

  • <?php
    $count = 0;
    $your_repeater = get_field('your_repeater');
    if($your_repeater){
       echo '<div class="headerrow">header</div>';
       while( have_rows('your_repeater') ): the_row();
       $count++;
       $my_field = get_sub_field('my_field');
       echo '<div class="row">'.$my_field.'</div>';
       if ($count % 5 == 0) {
          echo '<div class="specialrow">subheader</div>';
       }
    endwhile;  
    }
    ?>

    with that code every 5 row a additional row is added (always the same)
    if you need each 5 row totally different code, replace
    if ($count % 5 == 0) with if ($count == 5) and add a if-loop for each additional 5 rows