WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Archives outputting all child categories...how to limit? (3 posts)

  1. Craig Sunney
    Member
    Posted 4 years ago #

    Hello all.
    My first post here. Hope someone can help. Existing solutions stopped working on WP2.7

    This is about archive pages.

    While building a test site, I have noticed that WP lists an output of posts from all of a parent's sub-categories as well as the parent category.

    Said differently, on archive page "cat_parent" wp will also list posts from child_cat1.... child_cat2...child_catn
    and
    grand_child_cat1...grand_child_cat2...etc

    How can I tell wordpress.

    On archive pages....just list posts from this category only, ignoring any child_category post, and ignoring grand_child_category posts too. Thanks wordpress :)

    Craig
    P.S. I'm using Thesis theme, so ideally a custom function would be ideal for the custom_functions.php file. A styling class would be super too :) But all contributions welcome.

  2. MichaelH
    Member
    Posted 4 years ago #

    Could try this in your category template just before your loop:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $current_cat = get_query_var('cat');
    $args=array(
      'category__in' => array($current_cat),
      'paged' => $paged
    );
    query_posts($args);
    ?>
  3. Craig Sunney
    Member
    Posted 4 years ago #

    MichaelH

    Thank your for the reply!. This one took all weekend to workout.
    @Kristarella solved it. Documented here: WordPress: Exclude child categories from category archives

    Full workings for #Thesis hashed out here in DIYthemes forum

Topic Closed

This topic has been closed to new replies.

About this Topic