Hiding an ACF Repeater if empty in a Grid cell layout

Hi,

I’m baffled and very confused with conditionals and how to hide an element if it’s empty

I’m trying to hide a cell in a grid element if the content of the ACF repeater has no entries

I have an CPT called Aircraft which contains the specifications for an aircraft i.e. Tech spec, performance and armaments that it can carry. The armaments areas has several sub-types (guns / missiles/ bombs and external stores ). Some of my aircraft for example cannot carry missiles so I want to hide that Grid cell if the ACF repeater is empty.

My acf setting up is as follows

  • Group > Repeater > text item. i.e Armaments > Missiles > Missile name

I’m using the layout editor to create a master layout that my CPT will populate and it’s all working expect being able to hide the cell if there is no information present. My layout area is as follows

  • Section > Grid Element > Cell > in the Cell I have a text element as a title and then a list element displaying the ACF repeater information as Dynamic content.

I’ve tried using the conditions and can either hide it totally or reveal it totally but can’t seem to work out how to hide it if it’s blank and so it if it’s got entries.

Can anyone help ?

Hello @Kennyboy7,

Thanks for writing in!

To hide the ACF Repeater, please use the “Looper Out is Empty” condition.

If this is not helping, provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

Sorry guys tried that and it didn’t work.

Can you have a look please I’ve added a secure note to my original post.

Hi @Kennyboy7,

Try using a condition that will test your missile field group if it’s not empty

{{dc:acf:post_field field="KEY"}}

And also make sure that the column containing the headline Missile is inside the Looper Provider.

Hope it helps,
Cheers!

Hi sorry I have re-created the account listed in the secure note and updated the details and tested it so could I ask you try again please.

Another question, using the Layout designer I haven’t added any Looper Providers but simply added dynamic content links and all my content is working, is I’m assume it has automatically added one for the whole template when I selected Posts > Aircraft ?

Hi @Kennyboy7,

If you are using the Single Layout, you don’t need to use the Looper to show the data. The dynamic content tag will show the data based on the page you are visiting. If you are required to show the number of products using any loop, please use the Looper Provider in that case only.

Hope it helps.
Thanks

Hi tried this and still no luck.

I’ve tried just making a new section with a text element and the list element with it’s own looper provider and consumer but it still won’t disappear if empty.
Could the problem be the Provider is on the row and then the list has one as well ?

Hi @Kennyboy7,

Thank you for letting us log in, as I thought your Text/Headline element (Missiles) is not inside the Looper provider (https://prnt.sc/133wdrb). Please restructure this that the Text Missile will be inside the Looper provider so the condition can evaluate it.

Provider Output is not empty is another condition that you can apply to that text so it will not show if the Looper provider is empty.

Cheers,

hi,

That didn’t work it creates another problem. If you place the text (headline) inside the looper it appears in front of every single list entry

.

What I actually am trying to achieve is to have a title (missiles) and looper list item ( the missile name) only display if list items exist, if list items don’t exist don’t want the title to appear. i.e so no-one know the “missiles” area was even on the page.

Thank you for help so far in trying to solve this but I’m going to have to re-think this as what I believed to be simple is proving to be very time consuming and proving impossible to achieve.

Hi @Kennyboy7,

I have tried to check by logging into your website, but unfortunately, the previously given credentials are not working. Can you please check and send it once again.

Thanks

Strange I haven’t changed the password ?

I have reset the password and tested the login, updated the secure note in the original message.

Hi @Kennyboy7,

I went ahead and enable the Looper Consumer at the parent List element to get the Dynamic Content value in the Text element. I also added the {{dc:looper:index}} conndition to the Text element to show only for the First Loop. It makes the value shown once if the loop contains the data in it.

aircraft-Layouts-Pro (1)

Thanks

Amazing work thank you so much for figuring this out and I wish I had thought about using the looper index count to restrict what is displayed.

We can close this post as solved.

Hello @Kennyboy7,

Glad that we were able to help you. Please feel free to reach us if you have any queries regarding our theme and theme settings.

Thanks

1 Like

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