Forums

Hide Child Posts (2 posts)

  1. andrewhheller
    Member
    Posted 10 months ago #

    Hello,

    How can I hide child posts under a parent category? For example, if I click on a parent category archive I only want to see the posts from that parent category and hide all posts from child categories.

    When I click on the child category archive I'd like to only see the posts from that child category.

    Thanks,
    - Andrew Heler

  2. alchymyth
    The Sweeper
    Posted 10 months ago #

    you will need to edit category.php (if your theme does not have a category.php, make a copy of archive.php and save it as category.php)

    before the start of the loop, add a custom query;
    example:

    <?php global $wp_query;
    $args = array_merge( $wp_query->query, array( 'category__in' => array(get_query_var('cat'))) );
    query_posts( $args ); ?>

    http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note

Reply

You must log in to post.

About this Topic