Support » Fixing WordPress » 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>";
    			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>";
    			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.


  • The topic ‘Parent and Children Categories in Sidebar for Single post’ is closed to new replies.