Checking for subsub category and echo it.
-
$categories = get_categories('hide_empty=0&parent=16’); foreach ($categories as $category) { $cat_ID = $category->cat_ID; $inrCategories = get_categories("hide_empty=0&parent=$cat_ID"); foreach ($inrCategories as $inrCategory) { if($inrCategory->count == 0) { continue; } //Display the sub category information using $category values like echo '<h2>'.$category->name.'</h2>'; echo '<ul>'; foreach (get_posts('cat='.$category->term_id) as $post) { setup_postdata( $post ); echo '<li><a href="'.get_permalink($post->ID).'">'.get_the_title().'</a></li>'; } echo '</ul>'; } }
Basically this code check whether a post has any sub sub category under a sub category, if yes echo sub category and the title of the post.
I would like to add the sub sub category to the front of the title. Am struggling to do so. Any help would be much appreciated. Thanks in advance.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Checking for subsub category and echo it.’ is closed to new replies.