Showing the custom taxonomy parent term and child term of a post

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.

Read More

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

Related posts

Leave a Reply

1 comment

  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.