I've got a category structure that's 5 levels deep. when coming back the groups for any publish, these groups aren't in almost any particular order. I have to discover the last child category for any publish.
If you work with them informed, you could attempt this:
<?php the_category("", "single"); ?>
Ref: the_category
===== Up-to-date =====
Outdoors the loop:
<?php the_category("", "single", $post->ID); ?>
You might like to try wp_get_object_terms
$categories = get_the_category();
$last_category = $categories[0];
foreach($categories as $i => $category)
{
if($category->parent == $last_category->cat_ID)
{
$last_category = $category;
}
}