Archived topic
Hide section automatically if there are no posts to show
3 replies · Started by Encarni on January 25, 2020
Hi there,
Love the theme, I’m learning coding a lot :D
I am designing an animal shelter webpage and using sections for showing a row with a gallery of published custom posts in a specific category, with the help of WP Show Posts. This posts will move to another category at some point.
It works like this:
· A puppy is in adoption: post in category “In adoption” ==> It is showed in the home section “Puppies in adoption”.
· This same puppy is adopted: the post category changes to “Adopted” ==> It disappears from the home section.
Is there a way to hide this whole section when there is no puppies in adoption? I only get the option to show the text “Sorry, no posts were found”, but I want the whole section is gone from the homepage.
I’ve found this thread in the forums but I’m not sure if it has something to do with my question –sorry, I’m a self-taught coder and not sure about a lot of things.
Thank you in advance!
Hi there,
Unfortunately the topic you found won't work for this.
I don't think there is a way to achieve what you have in mind as Sections have no way of knowing is the shortcode has content or not.
You would need to add/remove that section manually.
Hi Leo,
So sad to hear that.
I will have to adapt my design and think about an alternative section for that space when there are no posts to show. It would be great to have a section library with templates ready to use in these cases. Just a suggestion... ;)
Thanks a lot!
Thanks for your inputs!