Is there a way to count how many times a repeater field has occurred, and after 3, add some HTML? I have a bunch of columns that I need to clear after every 3rd column.
UPDATE: I was able to get to add a clear after 3 posts, but I’m having trouble getting to go after every three posts. Will update if I figure it out.
UPDATE 2: Figured it out. I was just trying to reset the loop outside in the wrong spot. Here’s my code for anyone who needs help:
<?php $repeaterCounter = 0; ?>
<?php if( have_rows("repeater_label") ): ?>
<?php while( have_rows("repeater_label") ): the_row(); ?>
<?php echo get_sub_field("sub_field_label"); ?>
<?php $repeaterCounter++; ?>
<?php if ( $repeaterCounter == 3 ) { ?>
<div style="clear:both;"></div>
<?php
$repeaterCounter = 0;
}
?>
<?php endwhile; ?>
<?php endif; ?>