Support » Fixing WordPress » Child categories display only??

  • Resolved jarvis88



    I have searched the forums and it just seems nothing helps! So someone please help!! I have a bunch of caregories with children, grand children, and even more grand children.

    I have used a plugin to stop a child categories’ posts to display in its parent category aswell. Which works fine…

    But now the parent category is empty and contains no information. So I would like to display the current categories children on the page. I dont have a category.php so my archive.php is being used for the display of categories.

    I have tried using this…

    				if (is_category()) {
      					$cat = get_query_var('cat');
      					$parent = get_category ($cat);
      					if ($parent->parent) {
        					wp_list_categories ('child_of=' . $parent->parent);
        				} else {
        					wp_list_categories ('child_of=' . $cat);

    but it only displays that current categories title and link!

    Please help!!


Viewing 4 replies - 1 through 4 (of 4 total)
  • Sorry to bump this guys…. But I really need help with this!! Its a matter of life and death!!

    Any help much appreciated!!

    Okey, somehow I missed this in the codex!

    Only Show Children of a Category

    The following example code generates category links, sorted by ID, only for the children of the category with ID 8; it shows the number of posts per category and hides category descriptions from the title attribute of the generated links. Note: If there are no posts in a parent Category, the parent Category will not display.

    <?php wp_list_categories('orderby=id&amp;show_count=1
    &amp;use_desc_for_title=0&amp;child_of=8'); ?>

    The only problem is that if there is no posts in a category it will not display the children of that category as stated in the above codex paragraph…

    Some of my categories are there only for navigation and has no need to contain posts, just its children which in return has posts.

    The reason I want the empty parent category to display its children is so that a user doesnt end up clicking on that parent and finds no content. So by displaying its children I provide a kind of index to that parent!

    Please help someone!!
    I don’t like talking to myself here…. LOL!!

    this is why I say never give up! Solved the problem myself!!!!

    This is what I did if anyone wants to know for future reference…

    <div class="center-cat"><!--display child cats-->
    <?php if (is_category('3')) { wp_list_categories('orderby=id&amp;show_count=1&amp;title_li=&amp;use_desc_for_title=0&amp;child_of=3'); } ?>

    Okey, the ‘3’ is my category number… the ‘if is category’ is there so that the childs of cat 3 will only display on the ‘3’ category and not on any of the other categories…

    the rest of the parameters is difined in the codex… look there..

    paste the code in the php template file that the categories are displaying on (eg, category.php or archive.php) and make sure you paste it outside the loop… else your category would need a post to display the code you pasted…

    hope this helps someone….

    Thanks for helping forum….


    thank you thank you thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Child categories display only??’ is closed to new replies.