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.

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
add comment

2 Answers 2

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
add comment

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
add comment

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.