views:

25

answers:

2

I have a category structure that is 5 levels deep. when returning the categories for a post, these categories are not in any particular order. I need to find the last child category for a post.

A: 

If you are using them in the loop, you could try this:

<?php the_category("", "single"); ?> 

Ref: the_category

===== UPDATED =====

Outside the loop:

<?php the_category("", "single", $post->ID); ?> 
PeterWong
I need to get the child category outside the loop using the post ID.
InnateDev
Added back the 3rd param :D. The 3rd param is the post's ID, I shouldn't assumed you are in the loop.
PeterWong
A: 

You might want to try wp_get_object_terms

kovshenin