-
Ruanna
Thanks to your support threads I have learned to use a snippet to hide a label or container if a custom field is empty.
But I need to do this with an ACF taxonomy too. Here’s a screenshot. If “Sub-Type” is empty, as it is in the screenshot, how do I hide the label and/or container?
Thank you,
Ruanna -
Fernando
Hi Ruanna,
For reference, can you share a link to where that field is empty and another one where that field is filled? I’ll assess what we can do afterward.
-
Ruanna
Thanks Fernando, see info in private below.
-
Fernando
Can you add a class of
cu-acf-fieldto the Headline Blocks for the ACF fields?Then, add this CSS:
.gb-grid-wrapper.gb-grid-wrapper-d4110c6c > .gb-grid-column > .gb-container > .gb-container:not(:has(.cu-acf-field)) { display: none; }Let us know how it goes.
-
Ruanna
Thanks Fernando. I added the css to styles.
Here you can see the class on the “SubType” headline block: https://share.cleanshot.com/C5gJn8Km
And here are the results: https://share.cleanshot.com/gbFQgDM0
Here’s the class on the container that wraps both label and taxonomy (I’d prefer to hide the entire container): https://share.cleanshot.com/SBFqzbV9
And the results: https://share.cleanshot.com/f2NpKLgc
-
Hi there,
what is the taxonomy slug ?
-
Hi David, it’s property-subtypes
-
Try adding this CSS to your site:
article:not([class*="property-subtypes"]) .property-subtypes { display: none; }then select the container you want to hide and give it a CSS class of:
property-subtypesWhats this doing ?
WP has a
post_classfunction which WP, themes and plugins use to add classes to thepostelement.
And that includes Taxonomy terms.That CSS checks our article tag, and if if does not contain a string that matches your tax anomy then it will hide the
property-subtypesblock… -
Ah Ha! That works. And it makes sense. Thank you.
-
Awesome – glad to hear that
-
Ruanna
Hi – it’s two years later and I’m trying to implement this CSS on a different block, but no success.
The taxonomy is “features”
The class I’m using is “nofeatures”
/* featured props 2026 single – hide features if none exist */
article:not([class*=“features”]) .nofeatures {
display: none;
}When I add class “nofeatures” to the container block as shown here:
https://share.cleanshot.com/5RS295T3The container is hidden regardless of whether features are checked or not checked. So I’ve disabled the CSS for now, so that you can see what I am trying to do here.
Property with some “features” checked:
https://share.cleanshot.com/DvHMSnHV
https://dev-prerealtm-prendamano-real-estate.pantheonsite.io/listings/16-brienna-court-staten-island-ny-10309/Property with no “features” checked:
https://share.cleanshot.com/ZY81dRPh
https://dev-prerealtm-prendamano-real-estate.pantheonsite.io/listings/1388-richmond-terrace-staten-island-ny/NOTE
I’m using a snippet that Ying supplied on another ticket, not sure if that might be complicating things:
https://generate.support/topic/container-to-list-ol-or-ul/#post-175136Thanks, and I hope it’s okay that I added on to an old ticket, but it’s the same topic I think.
-
Hi there,
I can not tell if your CSS has format issue as you didn’t wrap it with the code tag.
Just try this instead, it should work.
article:not([class*="features"]) .nofeatures { display: none; } -
Ruanna
I see. My css somehow used curly quotes, yours does not, and that seems to have made all the difference.
Thank you Ying!
-
You are welcome 🙂
- You must be logged in to reply to this topic.