Home › Forums › Add-ons › Repeater Field › Assign classes to repeater divs in iterations of 3 › Reply To: Assign classes to repeater divs in iterations of 3
Here is the solution in case anyone is wondering:
<?php
if( have_rows('slide') ):
$i = 1;
while ( have_rows('slide') ) :
the_row();
// Check if we've reached our limit, and if so... start again!
if ( $i > 3 )
{
$i = 1;
}
?>
<div class="slide num-<?php echo $i; ?>">
<p><?php the_sub_field('text1'); ?></p>
<p><?php the_sub_field('text2'); ?></p>
</div>
<?php
$i++;
endwhile;
endif;
?>
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.