Category exclusion works on archive but not single
-
Hi all
I have two parent categories, ‘Portfolio’ and ‘Blog’. ‘Blog’ has several child categories. I use the code below in my sidebar so that on an archive page for the ‘Blog’ category, my category list shows only the child categories. This works fine.
However, when I then view a single entry from that archive page, the sidebar shows a category list that includes the parent categories.
Anyone got any ideas?
<?php if (is_category()) { $this_category = get_category($cat); } ?> <?php if($this_category->category_parent) $this_category = wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent."&echo=0"); else $this_category = wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0"); if ($this_category) { ?> <ul> <?php echo $this_category; ?> </ul> <?php } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Category exclusion works on archive but not single’ is closed to new replies.