0

Let's say I got the following categories:

Style
  |
  + Shoes
  + Pants

If I make a post and put it in the Style and Shoes category, it will list them alphabetically instead of hierarchically. So it would list it as Shoes, Style instead of Styles, Shoes.

How can I do this? I tried using "the_category('> ', 'multiple')" but that outputs "Style, Shoes, Style"

Thanks!

1 Answer 1

1

You could fetch the post categories, then pass them into wp_list_categories to take care of displaying them hierarchally.

Something like..

wp_list_categories( array( 
    'include' => array_keys( get_the_terms( $post->ID, 'category' ) ), 
    'title_li' => '' 
) );

Hope that helps.. :)

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.