I wouldn’t consider this any better/worse than Kaiser’s option, but just different. Why not use get_category_parents
on the parent category and then (optionally) append the current category?
I haven’t tested this, but something like the following should work:
$cat_id=7;//current category's ID (e.g. 7)
$separator="»";//The separator to use
$category = get_category($cat_id);//$category is the current category object
$parent_id = $category[0]->category_parent //category's parent ID
$ancestors = get_category_parents($parent_id, true, $separator);
Then optionally add the current category’s name:
if($ancestors){
$breadcrumb = $ancestors.$separator.' <span class="active-cat">'.single_cat_title().'</span>';
}else{
$breadcrumb = '<span class="active-cat">'.single_cat_title().'</span>';
}
echo $breadcrumb;
EDIT:
It turns out this almost exactly how WordPress produces the output: get_category_parents
calls itself recursively (see here), so with this method you are essentially ‘stopping it early’, and manually completing it. There are no hooks that can achieve this effect however.