ACF: Repeater within Group

In this example, my ACF group is named services and the repeater sub-field is named services_list.

Why would I use an ACF group?

The group feature in Advanced Custom Fields is useful when organizing both the dashboard user interface as well as the data. In my markup below, I added minimal HTML which hopefully helps a bit with clarity.


// Stop if there's nothing to display.
if ( ! have_rows( 'services' ) ) {
	return false;

if ( have_rows( 'services' ) ) : ?>

		<?php while ( have_rows( 'services' ) ) : the_row();

			// Services Sub Repeater.
			if ( have_rows( 'services_list' ) ) : ?>

			<ul class="services">

			       while ( have_rows( 'services_list' ) ) : the_row();

				       $image = get_sub_field( 'icon' );
				       $title = get_sub_field( 'service_title' );
				       $content = get_sub_field( 'service_content' );

				<li class="services-single">
					<img src="<?php echo esc_url( $image['sizes']['thumbnail'] ); ?>" alt="<?php echo esc_html( $image['alt'] ); ?>"?>
					<?php echo esc_html( $title ); ?>
					<?php echo esc_html( $content ); ?>

			       <?php endwhile; ?> 

		       <?php endif; ?>
		<?php endwhile; ?>
<?php endif; ?>
Additional Reading:

17 thoughts on “ACF: Repeater within Group

  1. Just fyi, you should take out the $service = get_field(‘service’); because it causes in error when initially starting the if/while loop. This will work when that is taken out.

    1. Hi Collin, that’s weird! It doesn’t break anything on my end. But you’re right, you can get rid of it without any effect. I’ll edit that line out in case it is causing errors for people.

  2. I had a nested repeater within a group within an options page, haha. Custom field Inception! This helped me out today, thank you.

    1. Hi Matt,

      Same problem on my end, but I’m kind of lost on how to show the content of the nested repeater. How did you proceed?

      Could you share your code?


  3. As everyone has said above, this has truly helped me. Thank you for sharing, this type of clarity is rarely shown so simplistically. Sweet sweet working group/repeater loops.

Leave a Reply

Your email address will not be published. Required fields are marked *