get category parent name from multiple child category
-
The goal is to display parent name as top title for posts in child categories. This is what I’ve come so far:
<?php $categories = get_categories("child_of=64"); foreach ($categories as $cat) { ?> <?php $parentcat = $cat->category_parent; echo get_cat_name($parentcat);?> <?php query_posts("cat=$cat->cat_ID&orderby=ID&order=ASC"); ?> .....the loop....
So the parent name is there ($parentcat), but because the parent category (cat=64) has 2 child, the parent name appear twice. What I need is like:
<h2>Parent Category Name</h2>
<h3>1st Child Name</h3>
<content>
<h3>2nd Child Name</h3>
<content>
etc….please help….
p
- The topic ‘get category parent name from multiple child category’ is closed to new replies.