Creating the Parent Category as a Link when using the_category
-
I have been ripping through the forums to find a way to have the: ‘Filed under: ‘<category>’ to display only the parent category, even if there are children involved. I have found a half resolution for this in the code below:
<?php foreach((get_the_category()) as $childcat) { $parentcat = $childcat->category_parent; echo get_cat_name($parentcat); } ?>
This code properly shows the parent category instead of the child. The problem is that it is not a link to the category. Can anyone with some php knowledge modify the code above to allow the parent category to be a link.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Creating the Parent Category as a Link when using the_category’ is closed to new replies.