Filter Loop by Custom Field (ACF Repeater)

I’m trying to filter a <Loop> by an ACF field. The problem is the field is inside of an ACF repeater. So I would need to do a <Loop> to get the field, and then filter by it?

Is this possible? If so, what is the correct syntax?

This is what I tried, and didn’t work, but that was to be expected:

<Loop type=listings field="supertag_id" field_compare="includes" field_value="29">
  <div><Field title /></div>
</Loop>

Do I have to do an initial query inside of a <Set> to then use in the real <Loop> or something to that effect?

I don’t think it’s possible to do the <Set> thing the more I think about it. That is just going to return all posts with their supertag_id but I still won’t be able to filter by it…

Does the filtering need to happen within the loop itself? Don’t have time to test it but I wonder if an approach like this would work. Obviously not very pretty and potentially not the most efficient if you’ve got a lot of data, but I imagine this approach would work.

<Loop type=listings>
  <If check="{Loop acf_repeater=supertag_id}{Field your_field_name /},{/Loop}" any_is value=23
    <div><Field title /></div>
  </If>
</Loop>

There are approx 2000 listings, so I’m guessing it’s is better to just do it in the loop to begin with? :thinking:

But yes, this does technically work

<Loop type=listings>
  <If check="{Loop acf_repeater=supertags}{Field supertag_id /}{/Loop}" any_is value="29">
    <div><Field title /></div>
  </If>
</Loop>

How bad is the performance here? haha

@julia Is there a better way?

Never mind. No need to waste anymore resources on this. I ended up doing it with a custom php filter on the query