-
Anonymous
Hi,
I’m wondering if I can make a header conditional on whether there is any content in the list items below it? For example, I have a “contributor” page element (link below) that has “external links” and “related Articles & Resources,” but for some contributors there won’t be anything here; so is there a way to make those headings not visible if there is not content for the query lists below? The content is post meta or post titles. I’ve included an image of the back end below.
Thanks!
Elisabeth -
Hi Elisabeth,
Yes, you should be able to create a condition post meta > has value > custom meta key > meta field name.
Then apply the condition to the heading or container.
-
Anonymous
Great, that worked! What about the column on the right (Related Articles & Resources)? The dynamic tag is post_title, because it’s within a query that searches for posts that have this contributor linked as a related person. I can’t tell how to set up the condition for a post_title. When I added it using the same setup you listed (post meta > has value > custom meta key > post_title), it made the heading go away for all contributors. Thanks!
-
Anonymous
I tried to set this up using Query parameter > has value > Custom parameter > parameter name (see image below) but that didn’t work either.
-
I don’t quite understand the second question.
Can you provide an admin login so I can check the settings?
-
Anonymous
Sure. I’ll include it below.
-
I see, it’s a relationship field, the condition post meta does not support this kind of field, unfortunately!
In this case, you can use CSS:
1. Add a CSS class to the container, eg.
hide-on-no-posts.2. Then add this CSS:
.hide-on-no-posts:has(.gb-loop-item) { display: block; } .hide-on-no-posts{ display: none; } -
Anonymous
Thank you so much!
-
You are welcome 🙂
- You must be logged in to reply to this topic.