Hide title element if provider output is empty

I’m having one of those days where a very simple thing is taking me hours!

Basically, I have a CPT with an ACF Post field, where the user can select a number of other posts within a sidebar of the main page. I’ve created a top-level DIV and set this as my ‘Looper Provider’. Then, within the DIV I’ve created a title, which will only display once as it’s not within the ‘Looper Consumer’. Finally, there’s another DIV, which is my ‘Looper Consumer’ and this happily loops through the output and displays the other posts as described above.

The issue I have is that no matter what I do, I can’t seem to hide the whole DIV if the provider output is empty. I’ve tried this on the ‘Looper Provider’ and the title always appears, even when the output is empty.

Screenshot 2024-07-25 at 18.47.57 Screenshot 2024-07-25 at 18.45.19

Hello @geoffmartyn,

Thanks for writing in! Your element structure can be:

DIV - Looper Provider
    DIV - will have a condition "Provider Output is not Empty"
         Headline

    DIV - Looper Consumer
         The Title
         The Content

If you are not familiar with the Conditions yet, please check this out:

Best Regards.

Thank you for your reply, @ruenel

I’m pretty sure I have it setup as you describe, but for some reason, on posts where there isn’t any consumer output, my title is still appearing. I’ll add a secure note - and would be very grateful if you could please take a quick look. It’s probably something simple!

Hi @geoffmartyn,

I have checked the layout and found that the Looper Consumer is not enabled for the Headline section, you need to enable it to set the condition. I will suggest you add a wrapper DIV enable the Looper Consumer on it, and move the Headline and Title inside it. And also remove the Looper Consumer from DIV with the Title.

Hope it helps.
Thanks

Hi @tristup - thank you for your reply and apologies for the delayed response.

I’ve tried what you suggested, but I still can’t get it to work. Perhaps I need to explain what I’m trying to do again.

I have an post-object ACF setup on a page called ‘Networks’, which allows the user to select one or more associated ‘project’ CPTs to display on the ‘Networks’ page within a sidebar. This should display a title ‘Projects’ in the sidebar and loop through the selected projects one at a time, displaying the project title which in turn links through to that project via the project permalink.

If the ‘associated projects’ post-object field is blank, then nothing should appear at all.

If I add looper consumer to the headline section, this will repeat every time a post-object is found.

Once again, I’m sure this should be possible, but I’m missing something obvious.

Thank you

Geoff

Hi Geoff,

I have checked your layout again and found that you have added the DIV as suggested but didn’t enable the Looper Consumer on it. If the Heading is repeating, you need to add the Condition as mentioned in the given screenshot.

Hope it helps.
Thanks

It does indeed help @tristup

Thank you for your advice and your patience! :slight_smile:

Hi Geoff,

Glad that we are able to help you.

Thanks

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