Support

Account

Home Forums ACF PRO Using the Repeater Field to render items in groups Reply To: Using the Repeater Field to render items in groups

  • There isn’t any real way to do what you want without temporarily storing the values in some way and then outputting them later since you want to split up the content of each row.

    Something like

    
    <?php 
      $i = 1; // starting at 0
      $rows = count(get_field('our_team_team')); // total rows
      $list1 = '';
      $list2 = '';
      while (have_rows('our_team_team')) {
        the_row();
        $list1 .= '<li>'.get_sub_field('team_member_name').'</li>';
        $list2 .= '<div>'.get_sub_field('Description').'</div>';
        if (($i % 3) == 0 || $i == $rows) {
          // divisable by 3 or last row
          ?>
            <ul><?php echo $list1; ?></ul>
            <div><?php echo $list2; ?></div>
          <?php 
          $list1 = '';
          $list2 = '';
        }
        $i++;
      } // end while have rows
    ?>