Categories hierarchy in post page
-
Good morning here! ??
I want to show the categories hierarchy in single post page, like in a sidebar but showing only the categories for this post.
For example, I’ve this categories hierarchy:
- Cat1 - SubCat1.1 - SubCat1.2 - Cat2 - SubCat2.1 - SubCat2.2
And I’ve a post with all categories asigned.
Now, in the single post page I show the categories in this way…
<?php foreach((get_the_category()) as $category) { echo '<a href="?cat='; echo $category->cat_ID . ' '; echo '">'; echo $category->cat_name . ' '; echo '</a>, '; } ?>
but this prints…
Cat1, Cat2, SubCat1.1, SubCat1.2, SubCat2.1, SubCat2.2
And I want to see …
Cat1, SubCat1.1, SubCat1.2, Cat2, Subcat2.1, SubCat2.2
Do you understand me? ??
It’s possible do that? How can I start?
Thank’s for your time.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Categories hierarchy in post page’ is closed to new replies.