WordPress.org

Ready to get started?Download WordPress

Forums

Display sub cat when u select a cat (2 posts)

  1. kirua
    Member
    Posted 4 years ago #

    Hi
    I have searched for this endlessly and really need some help, like many others.

    I have Subcategories within my Categories,respecting a hierarchy,
    exemple :
    ==========
    Mcategory
    -MSubcat1
    --Subcat1
    --Subcat2
    --Subcat3

    -MSubcat2
    --Subcat1
    --Subcat2
    --Subcat3
    ==========

    when i select Mcategory I want to display
    -MSubcat1
    -MSubcat2 only without posts

    and when i select for exemple -MSubcat2

    I want to display only
    --Subcat1
    --Subcat2
    --Subcat3 without posts

    the post will be show only in Subcat not in MSub on Mcategory

    And all thi will be displayed on the home page but not in the sidebar

    All my thanks

  2. kz
    Member
    Posted 4 years ago #

    If you mean category archives,
    create category.php file and edit like below:

    <ul>
    <?php
    wp_list_categories('title_li=&child_of=' . get_query_var('cat'));
    ?>
    </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags