WordPress.org

Ready to get started?Download WordPress

Forums

How to list other child categories (3 posts)

  1. thepenguins
    Member
    Posted 1 year ago #

    I've searched but couldn't find an answer to this. How do I list other child categories when the reader is inside a child category?

    For example, my category setup is this:
    A
    -a
    -b
    -c
    -d
    B
    -e
    -f
    -g
    C

    If the reader is in category b, I want it to list a,c,d.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    If the reader is in category b, I want it to list a,c,d.

    what is your exact idea of 'list'?

    the below should output an unordered list of those category links:

    <?php $parent = get_category( get_query_var('cat') )->category_parent;
    $sibling_list = wp_list_categories('echo=0&title_li=&show_option_none=&depth=1&exclude='.get_query_var('cat').'&child_of='.$parent);
    if( $parent && $sibling_list ) { echo '<ul>' . $sibling_list . '</ul>'; }
    ?>

    http://codex.wordpress.org/Template_Tags/wp_list_categories

  3. thepenguins
    Member
    Posted 1 year ago #

    I guess I just meant output.

    Thanks! This code works!

Topic Closed

This topic has been closed to new replies.

About this Topic