Let's say I got the following categories:

  + 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"



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.. :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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