show child categories on archive pages

Discussion in 'WordPress' started by sixrfan, May 16, 2010.

  1. #1
    how i can list the child categories on my category archive pages (http://castilloleathergoods.com/wordpress/category/hard-cue-cases/), right below where it says "Category: 'Parent Category Name'"

    ????

    here's the current code from my archive.php file:

    
    <div class="posttitle">
    		<?php if (have_posts()) : ?>
    		<?php $post = $posts[0]; ?>
    		<?php if (is_category()) { ?><h2>Category: '<?php echo single_cat_title(); ?>'</h2>
    		<?php } elseif (is_day()) { ?><h2>Archive for <?php the_time('F jS, Y'); ?></h2>
    		<?php } elseif (is_month()) { ?><h2>Archive for <?php the_time('F, Y'); ?></h2>
    		<?php } elseif (is_year()) { ?><h2>Archive for the year <?php the_time('Y'); ?></h2>
    		<?php } elseif (is_tag()) { ?><h2>Tag: <?php single_tag_title(''); ?></h2>
    		<?php } elseif (is_search()) { ?><h2>Search results</h2>
    		<?php } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?><h2>Archives</h2>
    		<?php } ?>
    	</div>
    
    PHP:

     
    sixrfan, May 16, 2010 IP
  2. strid3r

    strid3r Well-Known Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #2
    
    <?php // get current category
    $this_category = get_category($cat);
    ?> 
    
    
    <?php //show child category, fit it with your theme 
    wp_list_categories('orderby=name&show_count=0&style=none&use_desc_for_title=0&title_li=&child_of='.$this_category->cat_ID);?>
    
    PHP:
     
    strid3r, May 16, 2010 IP
  3. sixrfan

    sixrfan Well-Known Member

    Messages:
    354
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    thanks strid3r. but i tried that and the archive pages didnt appear at all. it was just a completely blank space. i guess there's some error in that code you provided. please advise. thanks!

     
    sixrfan, May 17, 2010 IP
  4. strid3r

    strid3r Well-Known Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #4
    Did you place the code outside the loop ?
    ahh, its only works if your category has childs.
     
    strid3r, May 17, 2010 IP