on my WordPress site, I'm developing a glossary list of novel writing terms, using tags and tags descriptions to draw definitions from. Currently, when any tag has more than 0 posts associated with it, it will link to that tag's archive page, allowing readers to further read up on the topic.
What I would like to achieve, is to have any tag that has exactly 1 post associated with it, to link directly to that post rather than the tag archive. I've been looking around for a solution, but can't seem to find any way to achieve that.
Any help would be greatly appreciated!
For reference, this is the current code:
<!-- If there are any posts for the tag, link to the tag archive -->
<li class="glossary-list">
<?php
if ( $tag['count'] > 0 ) {
echo '<a href="';
echo $tag['link'];
echo '">';
echo $tag['name'];
echo '</a></br>';
} else {
echo $tag['name'];
}
?>
<?php echo $tag['description'] ?></li>
Which leads to this, where 'cliffhangers' is linked and 'denouement' is not: