ACF Repeater Counter

Need to add varied styles to rows, but don’t want to program it in the backend? Or add ID numbers to rows in order to setup toggles?

ACF Repeater works with get_row_index() to count the number of rows present.

Check out this example using a counter to add a clear every second row:

if( have_rows() ):  while( have_rows() ): the_row(); 
	$count = get_row_index(); 
	
	// repeater content
	
	if ($count % 2 == 0) { echo '<div class="clear"></div>'; }
endwhile; endif;

Source.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.