5

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?

  • @HeroicNate: Are you sure subcategories do not already appear? In my testing on a vanilla Wp 3.0.1 site they do. Maybe you've got a plugin that's disabling them? Or maybe I misunderstand your question? – MikeSchinkel Aug 27 '10 at 18:00
  • Yes I'm sure. Lets say there is a category "News" and it has subcategories "Sub News 1" and "Sub News 2". If you go to www.blog.com/category/news you will only see what was posted in "News", but not in the subcategories unless those posts also have the "News" category checked. Currently the only way to see the sub categories would be to go to www.blog.com/category/sub-news-1 – HeroicNate Aug 27 '10 at 18:06
  • this is the same no matter what theme i use. – HeroicNate Aug 27 '10 at 18:08
  • Okay, I went ahead and added an "answer" so I could show screenshots. – MikeSchinkel Aug 28 '10 at 3:21
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?

| improve this answer | |
  • odd. It doesn't happen on this particular blog. This is for someone else so I'm not sure what else he has running to interfere with it. I'll have to look through it. – HeroicNate Aug 28 '10 at 17:43
  • @HeroicNate - Charity, eh? Haven't you ever heard that "No good deed goes unpunished?" ;-) (Of course I haven't either or I wouldn't be up here helping so much! :-) – MikeSchinkel Aug 28 '10 at 18:03
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy