ACF: Repeater within a Group on an Options Page

In this example, my ACF group is named services and the repeater sub-field is named services_list. This group is attached to my ACF Options page.

Why would I use a group within an Options page?

The group feature in Advanced Custom Fields is useful when organizing, even on an Options page. Depending on your usage, this UI can help guide the user in regards to theme & functionality choices. Similar to passing a $post_id to target a specific post object, you need to pass a second parameter to target the options page.


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

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

		<?php while ( have_rows( 'services', 'option' ) ) : 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' );

				<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 endwhile; ?> 

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

One thought on “ACF: Repeater within a Group on an Options Page

Leave a Reply

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