I have a custom taxonomy ‘portfolio category’, while i need to show all hierarchy categories of a portfolio post, for example

the post is under topcat -> childcat -> yetchildcat, i want to show ‘topcat, childcat, yetchildcat’ on the post page, but get_the_terms only return ‘yetchildcat‘, how do i get all?

5 Answers
5

There is a more generic function: it’s called get_ancestors() and it’s found in wp-includes/taxonomy.php

Leave a Reply

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