How can I get posts in a subcategory to display on it’s parent categories archive page?

Currently when you display an archive category page, it only displays it for the main parent, and doesn’t display any of the posts that may be in the subcategories under it’s parent.

How can I alter it so that for every category archive it will display all posts under it, including the subcategory posts?

Related posts

Leave a Reply

2 comments

  1. I ran another test and unless I’m loosing my mind child categories are definitely displayed on the category archive page in WordPress v3.0.1 (is that the version you are running, or are you on an earlier version?)

    Here are two screenshots, the first showing the category layout for my test install:

    WordPress Categories Admin Page showing Parent, Child and Grandchild Categories
    (source: mikeschinkel.com)

    The next screenshots is the category archive page for my test install showing three posts, each with one category selected; the Parent, the Child and the Grandchild category, respectively.:

    WordPress Categories Listing Page showing posts from Parent, Child and Grandchild Categories
    (source: mikeschinkel.com)

    So I’m 95% certain you have a plugin or some other code that is disabling your subcategories from displaying on your archive page. Can you add the list of plugins you are using to your question content?

  2. The relation between category and subcategory does not matter when you display a category because only one category (and not two or three like one main category and two subcategories) will be displayed.

    So you need to override the query. I know that this should be possible via filtering a wp_query hook (hook in, get all child cats, add them to the query arguments) but I can’t tell you this out of my head with some sample code. But maybe this little info is already helpful.

    The question indeed is nice for drill-down style content sites.