Hide an element outside of the ACF Repeater if Repeater on the same page has no values?

Hi!

On a Single post layout, I have a Heading element, and below it there is an ACF Repeater.

Some posts have values in the Repeater, and some not. I need to hide the headline above the repeater automatically, if nothing is placed inside it.

I have tried to set the condition on the Headline with the ACF Post field, but none of the fields from the repeater are getting listed. I understand that the headline is outside of the repeater’s loop, but they are both on the same post. I need to solve this somehow. Is there any way to do it? Thanks!

Hi @Misho,

Sure! This is possible, but requires a bit of setup. The only way to do conditions based on a Looper Provider is if you are inside of it. You might need to do a structure like this:

  • Section (Looper Provider)
    • Row
      • Column
        • Heading (with Element Condition)
    • Row (Looper Consumer)
      • Column
        • Elements that use ACF fields

Essentially you’ll just need to pull your Looper Provider to a higher point on the page so the Heading can be aware of it having contents or not.

1 Like

Ah, that makes sense!

For some reason I thought that anything inside the Provider is going to repeat itself, but that actually happens only if the Provider is on the same container as the Looper.

This is fantastic. it opens a lot of various possibilities. :slight_smile:

Thanks @alexander!

On behalf of Alex, you’re very welcome, Misho!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.