ACF Repeater Loop


the acf_repeater loop is not reseting properly.

If I run following code to get the first line of an acf_repeater:

<Loop acf_repeater=repeater_name count=1>

it works properly and I get only the result of the first repeater item.

When I now add directly below the loop another loop for the same repeater like

<Loop acf_repeater=repeater_name >
  <Field repeater_subfield /> // Shows only two of three items leaving the first one out

the results leave out the first row I just looped.

So I need to add between both repeaters following code to get the full list again.

<Loop acf_repeater=repeater_name ></Loop>

resulting to following code:

<Loop acf_repeater=repeater_name count=1>
  <Field repeater_subfield />

<Loop acf_repeater=repeater_name ></Loop>

<Loop acf_repeater=repeater_name >
  <Field repeater_subfield /> // Now showing all three items of the repeater

This does not seem to be the best way to have it. :slight_smile:

1 Like

Thanks for the heads up! This doesn’t seem like expected behaviour to me. I’ll pass this along to the dev team :slight_smile:

Thanks for supplying your workaround, too! I’m glad you were able to make it work in the interim

1 Like


same behaviour on my script with an ACF array and the missing possibility to address a specific row. I can only address “count=1” for the first row but I have some Arrays with three rows and “count=2” or “count=3” etc. doesn’t work. :smiling_face:


Hi all,

Related issue, i can’t get an exclude parameter to work in an ACF Relationship loop.

<Loop acf_repeater=repeater_name exclude="123">
  <Field title /> // Post with ID 123 is not supposed to be returned

The Post with ID 123 is still returned in the loop.

@besim could you clarify what you mean by this? I’m not sure what you mean when you refer to “rows” or what exactly an “ACF array” is. I assume you mean that you have an ACF repeater field and you’re able to limit your loop to one item in the repeater field using count but you’re not able to limit your loop to two or three items. Is that right?

@avanti Query parameters are loop-type-specific, so I’m not sure that query parameters from the post loop type like exclude are even supposed to work on an ACF relationship loop type (or a repeater loop type for that matter). I think the idea here is that an ACF relationship field is simply a list of posts, it’s not a query, which means you can’t filter it because it’s simply looping through the posts you’ve defined in the relationship field. Same idea with the repeater field, L&L isn’t querying data, it’s just looping through the information in your field. It is possible to sorta “convert” an ACF relationship loop into a post loop, at which point it actually is querying your posts and you’ll be able to use all the query parameters from the post loop type.

<Loop type=post post_type=post include="{Field acf_relationship_field_name}">

That being said, I’m not sure if the specific exclude parameter would work because then you’d effectively be saying “loop through these specific posts, but also don’t loop through this same post I’ve already told you to loop through” which doesn’t work logically. Might still work though so it’s worth a try. Failing that, maybe you could achieve that with something like this:

<Loop type=post post_type=post include="{Format replace=123 with=''}{Field acf_relationship_field_name}{/Format}">

Maybe there’s a better way to work with the Format tag so you’d have to tinker around with that, but I think you get the idea. I’m not sure this is a bug so much as a logical limitation that’s not fully explained in the documentation. I imagine you could approach this the same way with a repeater field, it would just depend how your repeater is set up and what fields you’ve defined inside it.

In any case, we definitely need to improve the ACF page of the docs to clarify this.

Hi again @benjamin,

Thank you for the explanations and examples, i understand an ACF loop is different from a standard WP Posts query.

But they both loop through Posts, so i guess there should be a way to filter the ACF loop so the current Post is not returned in the loop (that’s my goal).

I’ll check your Posts loop suggestion.

If not as a loop parameter, maybe at most simple by setting a conditional in the loop that would check the Post ID and exclude the current Post where the ACF Relationship is used on.

Very sorry all, i realize i confused ACF Repeater and ACF Relationship.
So, i posted in an unrelated topic… my apologies for the trouble.
And my initial code is wrong as well, i should have written:

<Loop acf_relationship=relationship_name exclude="123">
  <Field title /> // Post with ID 123 is not supposed to be returned

Just FYI, this is what i wanted to do, excluding the current Post from an ACF Relationship loop (not an ACF Repeater loop), and it works using a conditional like that:

<Set name=current_post><Field id /></Set>

  <Loop acf_relationship="relationship_name">
      <If field="id" is_not value="{Get current_post}">
        <li><Field title /></li>
1 Like

Hi Benjamin,

sorry for my late reply!

You assume right. I have an ACF repeater field with two rows. (I assume that the repeater field works like an array, so I use the “row” wording.)

In Custom Content Shortcode i can address explicitly a specific row with the “row”-attribute, like:

[repeater VARIABLE row=2]


Ah okay, understood. So it sounds like you need an offset feature for the Loop tag that was requested here.

For now, you could probably make it work with some conditional logic, like:

<If count in value="2,3">
1 Like

I am reviving an old thread here but I also needed a reliable way to target a repeater row.

@benjamin your recommended logic worked. The only downside is that if the repeater rows are reordered, it will change what is presented on the frontend.

I found a blog with a simple way to add a unique ID field to ACF with a little PHP. Working great so far. :slight_smile:

Once enabled you can target repeater or flexible content items like this:

<If check="{Field banner_id}" is value="6575401d978b0"> ...content...</If>