Is there any way that you can show a custom taxonomy's parent term and child of a post?

I'm currently using get_the_term_list() to display the custom tax terms of the post. The only problem is the order or arrangement of the terms, is alphabetical. What I want is to display the parent term first before the child terms.

Is it possible to manipulate/customize the HTML tags of the output?

What I want to display is something like this:

  • Parent Term
    • Child Term 1
    • Child Term 2

1 Answer 1


You can use the get_the_terms function, which will return an array of objects, each representing a category, and each containing the id of the term as well as the id of its parent, if it has one. You can use this data to determine which is the parent and which are its children.

Also see this post by Scribu on using a custom category walker to filter wp_list_categories, limiting output to terms associated with a particular post, giving you a proper tree structure.

  • Wow. That was fast. thank you very much. walker class is the answer to my problem.. its give me the appropriate output that i want. Thank you @Milo
    – CRookies
    Commented Jul 12, 2012 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.