emptying / removing html tag when no posts are visible

Essentially on my single post page, I want to display post highlights for each category. There are (3) main categories. When there are post highlights, the word post highlight appears in the H2 tag, if there is no post highlight, nothing is visible.

<h2>
<?php
function not_title_on_empty($title)
{
global $wp_query;

if(count($wp_query->posts) == 0)
{
$title = ”;
}

return $title;
}
add_filter(‘the_title’,’no_title_on_empty’);
?>
</h2>

Read more here:: emptying / removing html tag when no posts are visible

Leave a Reply

Your email address will not be published. Required fields are marked *