Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
share|improve this question

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.

share|improve this answer
    
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 Jul 12 '12 at 10:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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