Show the nearest category
I’ve been strolling around but I couldn’t find the answer.
My post is in the following categories : Forest > Tree > Bark
I would like to display
<a href="linktobark">Bark</a>on single.php
The code below shows me ‘Forest’
<?php $category = get_the_category(); echo $category->cat_name; ?>
Changing this to
$categorydisplays ‘Bark’ as wanted, but what about posts in the ‘Tree’ section?
Is there a way I can only show the youngest [?] category?
Thanks for helping me out, guys.
- The topic ‘Show the nearest category’ is closed to new replies.