• Resolved Jeremy

    (@jeremiahhenson)


    I’m developing a theme for someone, and they need a lot of category navigation. The goal is for each parent category page to display a list of its children categories. However, if we’re at the deepest categories where actual content begins, it should display posts instead of categories.

    So essentially I want to tell WordPress’ archive.php page that if is_category() and the category has children, display the kiddies. If it doesn’t, display posts.

    How do I tell WordPress to do that?

Viewing 2 replies - 16 through 17 (of 17 total)
  • This is great and I am using the snippet provided above:

    <?php // list child categories
    $cat_id = get_query_var('cat');
    
    $catlist = wp_list_categories('echo=0&orderby=id&title_li=&child_of=' . $cat_id);
    
    if ($catlist) {
    echo $catlist;
    } else {
    echo "Please don't print No categories";
    } ?>

    But if you go to a category without child categories it prints “No categories” which is a bit lame. Mainly because I can’t work out how to intercept that output. Any ideas?

    Thanks groomedmonkey;

    How about if you want to list the “sibling” categories?

    The code works great when I’m viewing the parent category, but as soon as I navogate to one of the children the list goes away; Ideally the list remains with the current category being viewed not being displayed in the list of siblings.

    Make sense?

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Display List of Current Category’s Children OR Posts’ is closed to new replies.