WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One would think that returning categories using wordpress functions would automatically display them in their heirarchy? Ive noticed that categories dont necessarily do this, so I am trying to find a way to make sure they are returned correctly.

share|improve this question
Are you really after using the walker class? Or was that just a proposal? – hakre Nov 6 '10 at 17:21
using the walker class is the only way to get categories in their heirarchy - should get_the_category($post->ID) display with heirarchy? – Innate Nov 19 '10 at 8:05

There is number of functions that deal with categories. Some are meant to be used with other code and mostly deal with category objects, some are meant for displaying on front-end and outputting HTML.

wp_list_categories() for example is meant for front-end presentation and defaults to hierarchical display.

share|improve this answer
just found this which should be useful: phpclasses.org/package/… – Innate Jan 2 '11 at 14:38
@Innate well that is also a walker-type class, just like WordPress uses internally. I'd try t ostick with WP rather than third party code for this. Does wp_list_categories() fit your needs? – Rarst Jan 2 '11 at 17:05

You could use get_categories with argument (child_of= 10, hierarchical=1)

I have done it and it traverses the categories tree starting from the category 10.

share|improve this answer

Your Answer


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.