WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show child of current category (3 posts)

  1. tomasi514
    Member
    Posted 5 years ago #

    Hi guys, this is my second sidebar where I list subcategories of category #18, how can I show make it dynamic and show subcategories list of current category instead ?Attempts not successful up to now...

    <div id="sidebar">
    <?php
    wp_list_categories('orderby=id&use_desc_for_title=1&depth=1&hierarchical=1&hide_empty=0&child_of=18');
    ?>
    </div>

    Thanks

  2. MichaelH
    Member
    Posted 5 years ago #

    Like this?

    <?php
    if (is_category()) {
    $cat = get_query_var('cat');
    wp_list_categories('orderby=id&use_desc_for_title=1&depth=1&hierarchical=1&hide_empty=0&child_of='.$cat);
    }
    ?>
  3. tomasi514
    Member
    Posted 5 years ago #

    Yihoo!
    I had tried same query found in another post but forgot the dot before $cat, big thank you Michael!

Topic Closed

This topic has been closed to new replies.

About this Topic