So basically, I have posts assigned to only subcategories and not to categories (this is so both of them get displayed in the premalink) and in the post page only the subcategory is displayed. I want to to display the parent category somewhere on the post page also.
I need something like this:
Sample Post belongs to SubcategoryName a part of Category
Buttercake belongs to Cakes a part of Desserts
I've tried this code:
<?php
foreach((get_the_category()) as $category) {
echo get_category_parents($cat, TRUE, ' » ');
echo $category->cat_name . ' ';
}
?>
But I keep getting this error:
Catchable fatal error: Object of class WP_Error could not be converted to string in C:\wamp\www\wp-content\themes\yoko\content.php on line 22
Does anybody know how to achieve this?