Check if subcategory has subsubcategories
-
This code checks whether current post has any subcategory under the category 16 and echo the subcategory(if there is any). I would like to further check for any subsubcategory listed under the individual subcategory and echo it after subcategory. Which means I would like to echo subcategory followed by subsubcategory. Am struggling to do so. Would appreciate any help! Thanks in advance.
<?php foreach (get_the_category() as $cat){ if(cat_is_ancestor_of(16, $cat)){ $parent = get_category($cat->category_parent); $parent_name = $parent->cat_name; echo $parent->cat_name . '<p>'; }}?>
- The topic ‘Check if subcategory has subsubcategories’ is closed to new replies.