WordPress archives for a single category
I've had a little rash of Google hits for variations on "wp_get_archives for single category" over the last couple of days. I hate to have to tell you this, people-from-Google, but that's the wrong template tag. Let's take a quick look at template tags for creating archives:
wp_get_archives() creates a date-based list of archives' pages. By default, they're monthly, but you can add a different type to them:
- <?php wp_get_archives('type=daily'); ?>
- <?php wp_get_archives('type=weekly'); ?>
- <?php wp_get_archives('type=yearly'); ?>
- <?php wp_get_archives('type=postbypost&limit=20'); ?> - postbypost creates links to individual posts, and you can limit the number of posts listed with the "limit" parameter
- There are a few other options for how the actual list of links is displayed; check the Codex for more information.
wp_list_categories() is the tag that creates a list of links to category archives. It can take lots more arguments than wp_get_archives: some of the more useful ones are:
- orderby - by default, the list is sorted by category name in alphabetical order, but you might also find it useful to order by count, so that your most-used categories are at the top of the list.
- exclude - which category number(s) do you want to exclude? Useful if you want to keep one or two categories out of the list. Alternatively
- include - if you want an automatically-generated list of links to specific categories.
- feed - if you want a link to the category's RSS feed, set the link text here, or
- feed_image - if you want, say, the orange RSS icon to link the feed, add its URL here.
- Check the Codex for lots more possibilities.
So to answer the question implied by the Google searchers, wp_get_archives() is never used for category archives, only for date-based ones. If you want category archives, use wp_list_categories().
Posted by Sue on August 19, 2009 in WordPress.








Actually - I came here looking for that exact thing - but just to clarify what I was searching for (and what others are probably looking for as well) is a way to hack (or a plugin or something) so that you can pass a category ID to wp_get_archives.
So for example - if I use wp_get_archives, it can display the list of archives with month and year. With the hack I'm looking for, I want it to look pretty much the same - but it will list all month/year for which there are posts in the category I passed into wp_get_archives. And then when you click on the link for the actual archive page - it gives you say a "JULY 2009" archive page - but again that only includes posts for the category I originally passed.
Anyway - Just figured I'd clarify what we google searches were looking for
My comment is to second Jennifer's of Sep 1 2009. I too am looking for a way to create an archive that is limited to a single category. Google keeps steering us in your direction. Hopefully someone will find a good answer and post it here. Thanks.
fyi, at http://wordpress.org/support/topic/234886 there was a link to this plug-in. Installed it and it works, creates an archive limited by category. Thanks.
I also found that plugin to be very useful and do exactly what I wanted to accomplish. Thank you! Hope this helps fellow googlers.
Now plugin didn’t work because of wordpress update
Maybe you know some alternative?
No, it doesn't work after 2.7. Sorry. Don't have time or inclination to fix it at the moment.