Conditionally adding a title above the post loop if $query->has_posts()
-
Hi there,
Is there an obvious way I’m missing to conditionally add a title to the top of the WPSP loop only if posts are found?
I’m displaying a post loop across all category pages with a dynamic tax_term passed through based on the current page, and sometimes the category doesn’t have any posts. In those cases, I’d prefer to completely hide the output. If there are posts though, I’d like to prefix the section with a title.
There don’t seem to be any hooks I’m able to use inside the main query/loop to add a title – the nearest I could find is ‘wpsp_inside_wrapper’, but it’s before the query is made and outside the $query->have_posts(), so won’t work for me.
If not, would there be any chance of a pull request being accepted to move the query up a little higher next to the inside wrapper and a new conditional hook for something like wpsp_conditional_title added if $query->have_posts() is true or something like that?
Thanks in advance for your help – plugin’s great alongside GP!
- The topic ‘Conditionally adding a title above the post loop if $query->has_posts()’ is closed to new replies.