Site icon Denis Bouquet

AFC reapeater in a group – WordPress

Building a block I had a group field and inside this group field a repeater. Here is how to use your repeater loop values inside a group’s loop with Advanced Custom Fields.

Use a repeater loop inside a group’s loop with Advanced Custom Fields

In order to loop through a repeater located inside a group, you should loop through the group and then your repeater within this group’s loop.

You need to use twice the “have_rows”

while ( have_rows( 'group_name' ) ) : the_row();
	 while ( have_rows( 'repeater_name' ) ) : the_row();
		$repeater_key = get_sub_field( 'repeater_key' );
		// ...	
	 endwhile;
endwhile;
Exit mobile version