Element Conditions with ACF Array - Hide Element if array empty

Hey :slight_smile: I hope you’re having an awesome day!

I have an ACF Gallery field returning an array. I have a looper provider setup to take that array and output the images - works perfectly! However, I’m wanting to hide that provider if the gallery is empty, but can’t seem to do it! Here’s what I’ve tried:

  1. On Provider: Using string condition, setting post meta is not blank.
  2. On Provider: Using string condition, setting acf meta field is not blank.
  3. On Headline element within Provider (not a consumer): Using number condition, setting looper count is greater than 0. But it seems the looper count is always 1, even when the acf gallery is empty.

Am I missing something again? Thanks!

Hi @conorseed,

Thanks for reaching out.
It will very difficult to recognize your problem without logging into it. Hope you will not mind sharing your website credentials. Please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– Exact Page URL or Layout where you are having this issue.
– WordPress Admin username/password

To create a secure note, click the key icon underneath any of your posts.

Thanks

Thanks @tristup :slight_smile: Secure note added to original post!

Hi @conorseed,

To hide an element if the field is empty, just use the string condition and add the ACF dynamic meta field and is not blank.

You can check the same thread here:

Hope that helps.

Thank you.

Hey @marc_a, Thanks for the response :heart:

Unfortunately, as stated in my original request, I have already tried that along with two other options and it doesn’t work. For your convenience, here’s what I already tried again:

  1. On Provider: Using string condition, setting post meta is not blank .
  2. On Provider: Using string condition, setting acf meta field is not blank .
  3. On Headline element within Provider (not a consumer): Using number condition, setting looper count is greater than 0. But it seems the looper count is always 1, even when the acf gallery is empty.

It seems that the string condition “ACF field is not blank” does not work when the ACF field is returning an array, which (again) is what my field is doing as it’s an ACF Gallery field.

Any further advice would be greatly appreciated :wink:

Hello @conorseed,

The {{dc:acf:post_field field="gallery"}} condition should be attached to the consumer element not on the looper provider element. You can also use the “Provider Output is empty”:

Kindly let us know how it goes.

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