Archived topic
Hiding empty Custom Field AND associated BLOCK Element Template Information
1 reply · Started by Tom on December 12, 2022
I have Custom Fields associated with a Custom Post Type. My CPT is "Positions' as in Job Positions.
Not all Custom Fields are required - this is by design as different positions require different fields.
I have created a Block Template to display the custom fields in my CPT.
All fields are present in my Block Template. I also created Labels for each custom field result, i.e.:
Label 1
Label 1's associated Custom Field.
Label 2
Label 2's associated Custom Field.
and so on...
However - Since not all custom fields are required - if they are not filled in - they do not appear.
But the Labels still do - which are manually generated in my block template for each field.
Is there a way to HIDE the labels if there is no custom field information present?
(I could not find a way to pass Custom Field Label through to the front end - which would negate the need for generating labels in the block template.
Thank you!
Hi there,
So in Block elements the Container Block has a special function in its Layout settings called: REMOVE CONTAINER CONDITION.
You can set it to No Post Meta and set the Field name.
Then you can add any associated blocks inside that.
Its something we will add to GB Pro in the future :)