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?

  • it is possible but you need to rebuild/change your code.
    you need to fill first all rows to variables or a array.
    and use that to echo values. (here i use variables)

    simple it would look like that:

    <?php
    $count = 0;
    $list_employee = '';
    $div_employee = '';
    while ( have_rows('employees') ) : the_row();
    $count++;
    $list_employee .= '<li><a href="#employee-'; //whole code for li (no echo!, nothing outside php, get_field instead of the_field)
    $div_employee .= '<div id="employee-'; //whole code for div (no echo!, nothing outside php, get_field instead of the_field)
     if ($count % 5 == 0) { //each 5 rows echo ul and div
    echo '<div class="tabz"><ul class="employees">';
    echo $list_employee;
    echo '</ul>';
    echo $div_employee;
    echo '</div>';
          $list_employee = '';
          $div_employee = '';
       }
    endwhile;
    if ($list_employee){ //if all rows are done but 1-4 rows left, echo them
    echo '<div class="tabz"><ul class="employees">';
    echo $list_employee;
    echo '</ul>';
    echo $div_employee;
    echo '</div>';}
    ?>

    try to modify your code like above, just the whole one. this should work.
    if not: show whole modified code and what the “error/problem” is.