How can i include the parent when listing sub categories?
-
Hi guys,
Im having a bit of trouble working out how to list sub categories of parent id, and to also show the parent in the list. For example, my site structure is something similar to…
Brands > Nike > Nike Golf > Nike Golf Clubs > Product/Post
Im trying to create a sidebar for the ‘Nike Golf Clubs’ category page so that it lists sub categories of the parent id, and includes the parent eg. Nike Golf. Like so..
Nike Golf
-Nike Golf Clubs
Nike Football
Nike BasketballThe code im currently using works fine but it does not show the parent which i would like to improve the sites navigation.
<?php
if (is_category()) {
$this_category = get_category($cat);
}
?><?php
if($this_category->category_parent)
$this_category = wp_list_categories(‘show_count=0&title_li=&child_of=’.$this_category->category_parent.”&echo=0″);if ($this_category) { ?>
-
<?php echo $this_category; ?>
<?php } ?>
If anyone could offer any help in fixing this i would be very grateful. Thanks.
- The topic ‘How can i include the parent when listing sub categories?’ is closed to new replies.