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
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.