Support » Fixing WordPress » List Current Category and its Sub-Categories….

  • I am trying to list the category and all sub categories of the current category or sub category page. So it I am on category 1, a list will show with category 1 and all sub-cats. If I am on a sub category of category 1, a list will again show with category 1 and all sub-cats….so the same list shows relevant to the current category, regardless of whether the current category is a parent or child.

    The following code works but it 1) requires me to add an entry for every single category 2) only lists sub-categories…. for each page, I am unable to list the sub cats and the cat simultaneously, if I add include:26, it will only list parent and if I add child_of=26, it will list children but not parent… any feedback appreciated!:

    <?php if (is_category(26)){ ?>
    
    			<ul><?php wp_list_categories('child_of=26&hierarchical=0&title_li=0&hide_empty=0&depth=1'); ?></ul>
    
    			<?php }elseif(is_category(22)){ ?>		
    
    			<ul><?php wp_list_categories('child_of=22&hierarchical=0&title_li=0&hide_empty=0&depth=1'); ?></ul>
    
            <?php }elseif(is_category(21)){ ?>		
    
    			<ul><?php wp_list_categories('child_of=21&hierarchical=0&title_li=0&hide_empty=0&depth=1'); ?></ul>
    
    		<?php }else{ ?>
    
    			<ul><?php wp_list_categories('orderby=ID&hierarchical=1&exclude=1&title_li=0&hide_empty=0&depth=1'); ?></ul>
    
    		<?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m looking for a dynamic way to tackle this issue too.

    I feel the anwer must be out there but haven’t found it yet…

    I think I can help you – maybe you can help my related problem.

    If I under stand you right – I have that working here

    http://www.verycraftygals.com/topics/discover

    On the left col Nav is the Cat name with the subcats

    You can see the cat is Discover and there are subcats – if you click on the subcat name in the center – it will take you to that page.

    The left nav will still show the discover button and the subcats.

    this is the code
    <div id="mmenu">
    <ul class="mmnu">
    <li> <img src="/images/Discover-Button.gif" alt="Discover" title="Discover very Crafty Gals" border="0" /></li>
    <li><?php $tcatname = single_cat_title();  ?></li>
    <?php wp_list_categories('orderby=id&use_desc_for_title=0&title_li='.$tcatname.'&child_of=10'); ?>
    </ul>
    <a class="top" href="/Store/index.php"><img src="/images/Our-Shops-Button.gif" alt="Visit Our Store" title=" Very Crafty GalStore Image"/></a>
    </div>

    </endcode>
    The problem I'm having is that the children aren't all displaying the right top banner - all the discover sub-cats should show the gal with the book - some do - some don't and I don't see why.

    DonnaNJ

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Current Category and its Sub-Categories….’ is closed to new replies.