Support » Fixing WordPress » Parent and Children Categories in Sidebar for Single post
Parent and Children Categories in Sidebar for Single post
-
How can I list the Parent and Children of a single post in a sidebar? I have two separate categories (each have sub cats). For example parent categories are called NEWS and BLOG.
I followed the examples provided in the CODEX and here is my code:
} elseif (is_single('')) { if (in_category('News')) { // we're looking at a single category view, so let's show _all_ the categories echo "<div class='SR'><div class='Categ'><h2>News</h2>"; echo "<ul>"; wp_list_categories('sort_column=name&optioncount=0&title_li=&hierarchical=0&child_of=&hide_empty=0&include=1'); echo "</ul></div></div>"; } elseif (in_category('blog')) { // we're looking at the blog category only, so let's show that only echo "<div class='SR'><div class='Categ'><h2>Blog</h2>"; echo "<ul>"; wp_list_categories('sort_column=name&optioncount=0&title_li=&heirarchical=0&child_of=&hide_empty=0&include=3'); echo "</ul></div></div>"; } else { // catch all for other categories echo "<p>My god, it's full of stars...</p>"; }
How do I keep the sidebar showing the PARENT and all CHILDREN of that particular single post? I do have subcategories for NEWS and BLOG but they do not show, only the parent shows.
Help?
- The topic ‘Parent and Children Categories in Sidebar for Single post’ is closed to new replies.