Forums

[resolved] when you are in a category show the subcategories in the sidebar (3 posts)

  1. Alyson
    Member
    Posted 1 year ago #

    when you are in a category...
    show the subcategories in the sidebar.

    Is it possible?

    I tried this code and did not work, nothing appears in the sidebar.

    <?php
        if(is_category()) { // are we on a category or archive page
          $current_category = get_query_var('cat'); // the current category id
          $category= get_categories( 'include='.$current_category );
          // if the parent category ID in the top navigation is the parent of the current category
          if($category[0]->category_parent == 3){
            $child_categories= get_categories( 'child_of='.$current_category );
            if(!empty($child_categories)){
              foreach ( $child_categories as $child_cat  ) {
                $categories[] = $child_cat->cat_ID;
              }
              $sub_children = implode(',', $categories);
              echo '<ul>';
              wp_list_categories('include='.$sub_children);
              echo '</ul>';
            }
          }
        }
      ?>

    change the ID (3) to your main menu option ID with all the child categories.
    $category[0]->category_parent == 3

    i'm, using this code..
    I acess the top Menu e when i click in one category ( have other subs ) nothing show in my left sidebar

    screen: http://img827.imageshack.us/img827/1816/categoriesz.png

  2. Alyson
    Member
    Posted 1 year ago #

    Somebody?

    I found a plugin to do this, but only work with pages ( Plugin -> Dynamic Subpages )
    I need something to work with categories.

  3. Alyson
    Member
    Posted 1 year ago #

    ok i found this plugin WordPress Folding Category List

    It does this!
    with option "show children categories only"

    http://www.lonewolfdesigns.co.uk/focal

    resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic