Last updated on April 17th, 2019 at 09:21 am
It is not difficult to get the name using the build in function from WordPress. You may use this for build your own plugin or list out the related post using the category data from the parent category.
Here is the PHP Code that can display out the name of the parent category.
<?php $category = get_the_category(); $parent = get_cat_name($category[0]->category_parent); if (!empty($parent)) { echo $parent; } else { echo $category[0]->cat_name; } ?>
Thanks for this!