WordPress Category Archive Widget Plugin


The WordPress Category Archive Widget displays a monthly or yearly archive of posts for one specific category. It is very similar to the WordPress Archive Widget except that it just displays one specific category’s posts, not all categories. It can be configured to either show a listing or pulldown by month or year with or without post counts.


Category Archive Options

From the Category Archive widget control, you can set the widget’s title, category, whether to display the archive as lines or as an unordered list or as a pulldown, whether to group by month or year and whether to show post counts.

Category Archive Display

The archive displayed as a list with post counts and the archive as a pulldown of years without post counts.


  1. Upload “wp-category-archive.php” to the “/wp-content/plugins/” directory.
  2. Activate the plugin through the “Plugins” menu in WordPress.
  3. From the “Widgets” page in WordPress drag the “Cateogry Archive” widget to the “Sidebar”.
  4. Configure the “Category Archive” widget controls, setting the “Title”, “Category”, “Display Style”, “Group By” and “Show Post Counts” fields.


How is the Cateogry Archive widget different than the built-in Archive widget?
The Category Archive widget lets you show posts for one specific category. The built-in Archive widget shows posts for all categories.

How come with permalinks on, when clicking on a month link, posts are shown for other months or other categories?
If permalinks are on, the permalink structure must contain the category, year and month for the Category Archive widget to work properly (e.g. /%category%/%year%/%monthnum%/%post_id%/).

With WordPress 3.0, you may also need to update the redirect_canonical function in wp-includes/canonical.php. See the “Permalink rewriting in 3.0″ support topic for more info.

Change Log


  • Added better support for permalinks.
  • Internationalized the month names.


  • Added options to show post counts and display as an unordered list.


  • Added option to display by month or year.


  • Displays monthly archive of posts for one specific category.

67 thoughts on “WordPress Category Archive Widget Plugin

  1. Thanks for the plug-in! It is just what I was looking for.

    I’m having one problem with it: the categories aren’t getting sorted by year. When I click on 2009, for example, I see the posts from all years. It’s probably because of my permalinks. I’m using a custom structure:


    Any ideas what I might do to get it to sort correctly?


  2. The plugin calls get_posts with orderby, which was modified in version 2.6 of WordPress. Are you using 2.6 or higher?

    get_posts(“numberposts=-1&offset=0&category=” . $category_id . “&orderby=date&order=DESC”);

  3. You might need the category, year and month to be in the permalink. Something like:




  4. Hi,

    This dosent appear to be working for me. The plugin is creating the widget, which is displaying the months with the count correctly, but when I click on the month/link it does not display a filtered list.

    You can see in this link if you click on april(1) you see all 9 of my posts.


    My permalink structure is: /%category%/%year%/%monthnum%/%postname%/

    What am I doing wrong?



  5. Hi,

    How can I make the names of the months change to my default language setting which is Dutch?

  6. To display the month names in the current locale’s language, try changing the line

    $current_year_month_display = date($display_format, $post_date);


    $current_year_month_display = date_i18n($display_format, $post_date)

    If it works, let me know.

  7. I have installed this plugin but it doesn’t work. When i have it set to list the category “daily-videos” it takes me to http://www.mysite.com/category/daily-videos/

    I have 3 months and it displays the amount of post per month per category correctly, however when i click on an older month it just takes me to that category. Please help.


  8. Has this issue been fixed yet?

    I too have the Month with the correct number of posts by the side, but when I click the month it shows all of the posts in the category, not posts created in that month.

  9. I have been trying to get this to work for the past two days with permalinks and I still can’t figure it out. Hugh… If you could please help me out with this that would be awesome.

    Thanks in advance.

  10. I think category, year and month need to be in the permalink, so


    will work, but



  11. I have it set to that now and it still doesn’t rewrite properly. Is there something else that can be causing this issue?

  12. I updated the code (v1.3) to work better with permalinks. When permalinks are on, the links to the category archive listings are in the format /category_slug/year/month or /year/month/category_slug. If permalinks are off, the links are in the form ?m=yearmonth&cat=cat_id.

    With permalinks on, it requires that %category%, %year% and %month% are part of the permalink structure.

  13. Upgraded to 1.3 from 1.2 and links are still in ?m=yearmonth&cat=cat_id format — is there anything else I have to do to get the new version to kick in? thanx

  14. What is your permalink structure? It will default back to ?m=yearmonth&cat=cat_id if the permalink structure doesn’t contain %category% and %year%.

  15. It’s set to the common “Day and Name” format, which explains why! Thanks for the quick response.

  16. My current permalink structure is:


    Do I need to change this to get this working? If so what should I change it to without messing up my current structure?

  17. OK I upgraded the plugin and used the following permalink structure:



    Thankyou for the great plugin Hugh!!

  18. I was wondering why the following permalink structure:


    works like a charm in WP 2.9.2, but not in WP 3 RC1. Is WP 3 lacking certain rewrite rules?



  19. Thanks heaps for this. I was worried a bit about what my client wanted but this fits it perfectly. I had a bit of trouble with the permalinks but the comments you left to other users fixed it straight away.

  20. Hi,

    First of all great plugin!
    I have two questions.

    1. Is there a way to add this via a function in my template files instead of via a widget?

    2. Is there a more safe solution than the canonical.php modification for WP3.0? So on updates it keeps woking…

    Thanks, ALain

  21. 1. I haven’t worked with templates before. I would think you could turn the code from the widget into a function the template could use.

    2. From what I can tell, there isn’t a way in WP 3.0 to show an archive listing of posts for a particular category and year and month if permalinks are set.

    So you either need to:
    a. fix canonical.php in WP 3.0,
    b. don’t use permalinks in WP 3.0 or
    c. use older version of WP like 2.9.2.

    Hopefully a future version of WordPress (3.2) will contain a fix.

  22. I was excited to find this widget, but I have the same issue, even after making the fix to canonical.php

    I am using the permalink structure: /%category%/%year%/%monthnum%/%postname%/

    Even when my URL says “../blog/2010/04/” I am seeing all blog posts instead of just those for April 2010.

    Has anyone else still had an issue after making the fix?

  23. Thanks for the suggestion… I changed my permalink structure, but still no luck.

    I upgraded to WordPress 3.0.1 tonight (and noticed that they fixed canonical.php) but whatever my issue is, is still present.

  24. this is just the kind of widget/plugin I was looking for – however, I was wondering whether there is a way to run it dynamically – let’s say I’m on a regular page, it should show all the posts by date/month – if I’m on an archive page of a specific category, it should just show the entries under that category


  25. Hi
    Great plugin! It’s a perfect match for the setup of our website :-)

    Maybe just one thing: On line 59 I had to change ‘&cat=’ to ‘&cat=’ in order to make the site pass the w3 validation.

    Nevertheless, great stuff.


  26. Chris can you paste your changes (the full line 59). I can’t tell the difference between ‘&cat=’ and ‘&cat=’ in your last message.

  27. Ooops. I meant that you can replace the & with &.amp; (you need to remove the . after the &. I had to put it in the commment, otherwise it would display another & :-/)

  28. Hola,
    Chris, could you please describe how to call this function in bare form (not as a widget)?

    I simply want to generate a good ol’ select with category archive months listed between tags…

  29. hey chris

    just come across your plugin. will this be updated for wordpress 3.1?

    I installed it but I couldn’t drag the widget across to my sidebar. It just didn’t work :(

    really looking forward to using this plugin.

    hope this gets upgraded soon :)

  30. @dude – use the widget logic plugin

    This plugin has huge potential but I am having problems with WP3.1

    My permalink structure is /%category%/%year%/%monthnum%/%post_id%/. I can see the link looks right when I mouse over. But WP redirects to the category, so it shows the entire category.

    How do I resolve this?

  31. See the category archive plugin FAQ.

    To get the plugin to work with permalinks in WP3.1, you need to update the redirect_canonical() function in wp-includes/canonical.php. On line 167, wrap the following code:

    $tax_url = parse_url($tax_url);
    if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=..
        parse_str($tax_url['query'], $query_vars);
        $redirect['query'] = add_query_arg($query_vars, $redirect['query']);
    } else { // Taxonomy is accessable via a "pretty-URL"
        $redirect['path'] = $tax_url['path'];

    in an if (is_tax()) block:

    if (is_tax()) {
        $tax_url = parse_url($tax_url);
        if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=..
            parse_str($tax_url['query'], $query_vars);
            $redirect['query'] = add_query_arg($query_vars, $redirect['query']);
        } else { // Taxonomy is accessable via a "pretty-URL"
            $redirect['path'] = $tax_url['path'];

    Note: No code changes are needed for WP 3.1.1 or higher (or WP 2.9.2).

  32. “the permalink structure must contain the category, year and month for the Category Archive widget to work properly”

    My structure is /%year%%monthnum%%day%/%category%/%postname%/ which satisfies the statement above, and I’ve wrapped the if conditional as above and per your faq, but it’s 404’ing.

    Do I take it that it will only work with exactly category/year/month etc. ie. ‘category’ has to come first?

  33. With further testing, /%year%%monthnum%%day%/%postname%/ is working for me fine, when combined with the hack to canonical.php

  34. Hi! Is it possible to change the names of the months to a language that isn’t the default language? I see that the code:

    $current_year_month_display = date_i18n($display_format, $post_date)

    is added to the wp-category-archive.php page. But this only set the language that I have in the WordPress backend. I want to have the archive months listed in norwegian language, and I use english as language in WP backend.

  35. It is a hack, but you could update the month names in the wp_locale object before calling date_i18n.

    $orig_months = $GLOBALS['wp_locale']->month;
    $GLOBALS['wp_locale']->month = array ('01' => 'januar', '02' => 'februar', '03' => 'mars', '04' => 'april', '05' => 'mai', '06' => 'juni', '07' => 'juli', '08' => 'august', '09' => 'september', '10' => 'oktober', '11' => 'november', '12' => 'desember');
    $current_year_month_display = date_i18n($display_format, $post_date);
    $GLOBALS['wp_locale']->month = $orig_months;

  36. Okey, could you please show how and where I add this code in the wp-category-archive.php page as I’m not so familiar with php?

Leave a Reply