I currently have the following trying to avoid showing tags (the icon in this case) when there aren’t any, but the icon continues to show up. Any thoughts?
<?php if ( is_singular() && function_exists('the_tags') ) : ?>
<p><i class="icon-tags"></i><?php the_tags('', ', ', ' '); ?></p>
<?php endif; ?>
2 Answers
Get a string value for the tags and print it only if there are tags:
$tags = get_the_tag_list('', ', ', ' ');
if ( "" !== trim( $tags ) )
{
echo "<p><i class="icon-tags"></i>$tags</p>";
}