Compact Archives


Maintenance and development of this plugin has been taken over by WpBeginner. Compact Archives can be downloaded from the WordPress plugin repository


My blog has posts going back over 11 years and the archive of posts by month in my sidebar was getting very much out of hand. In the search for a more compact way of displaying the monthly archive a plugin was born.

Compact Archive v1.0.6 displays the monthly archive of posts in three compact forms. It can be shown as a block suitable for the body of an archives page, e.g.:

2006: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2005: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2004: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

or in an even more compact form to fit nicely in a sidebar:

2006: J F M A M J J A S O N D
2005: J F M A M J J A S O N D
2004: J F M A M J J A S O N D

or in a numeric form:

2006: 01 02 03 04 05 06 07 08 09 10 11 12
2005: 01 02 03 04 05 06 07 08 09 10 11 12
2004: 01 02 03 04 05 06 07 08 09 10 11 12


  1. Upload the whole plugin folder (Compact_Archive) to your /wp-content/plugins/ directory.
  2. Go to your Admin|Plugins page and activate Compact Archive.
  3. Put<!--?php compact_archive(); ?--> at the place in your template where you want it to appear, e.g., in your sidebar:
  4. You might want to adjust your style sheet to make the months with no posts fade into the background.

The template tag, compact_archive, has some parameters:

compact_archive($style='initial', $before='



If $style == ‘initial’ (the default) the display will fit into a sidebar.

If $style == ‘block’ the display will be wide enough to fill the main column of a page.

If $style == ‘numeric’ the display will use numeric values for the months.

$before and $after wrap each line of output. The default values make each line of the archive into a list item.


The year link at the start of each line is wrapped in and months with no posts are wrapped in so you can differentiate them visually using your style sheet.

Compact Archive honours whatever kind of permalink WordPress is using and the month names and abbreviations are chosen in accordance with the language locale (WPLANG) set in wp-config.php.



The idea for this plugin comes from the SmartArchives plugin by Justin Blanton ( It is a rewrite of the ‘block’ half of his tag. I have added a very compact version that fits nicely in a sidebar.


  • 1. Stacy  |  August 24th, 2007 at 5:19 pm

    Oops…here’s the code on the page:

  • 2. tom  |  August 31st, 2007 at 1:23 am

    i have some problems using this plugin – the output inmy indexfile. i tried now severyl times to make it look like in your example – the list in a row

    i made a table and a class row but its not working. would be very nice if your time allows you to help me with my html(php) problem

    this plugin is exactly what i was searching for. hope to hear from you soon


  • 3. Nancy P Redford  |  November 1st, 2007 at 10:42 pm


    I wanted to ask for the code to insert into a sepearate page dedicated to my archives.

    I want to use the following format:

    => 2006: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

    And alsoto archive by “category”.

    Could you show me the code for each choice.

    Thanks in advance.

  • 4. Kahotep  |  November 25th, 2007 at 8:26 pm

    This is the coolest plugin ever. Thank you so much!

    Customizing was no problem. I even managed to tweak the plugin itself, without any problems.
    Awesome, awesome, awesome.

    Thanks 🙂


  • 5. manele  |  December 11th, 2007 at 3:47 pm

    i was looking for this solution for a long time! thx!


  • 6. Paul  |  January 22nd, 2008 at 5:09 pm

    I installed your similar posts plug-in earlier today and loved it. I’ve just finished “tweaking” your archives plug-in and I’m equally impressed.

    I’ve added an extra argument to your function, that will chop up the months into segments. I needed that functionality because my sidebar is pretty small. For instance, if you want it to drop to the next line after 4 months, just pass 4 as the fourth argument and hey-presto!

    You can see the amended compact archives plug-in (with a “6” passed to it) on the left of my blog at & if you want the amended source let me know and I’ll email it to you.

    Thanks again!

  • 7. Rob  |  January 22nd, 2008 at 5:34 pm

    Paul: That’s a good idea .. I’d love to see the source and maybe include it. Thanks.

  • 8. jess.  |  February 9th, 2008 at 5:34 pm

    The plugin is great — I referred to your archives template, in order to get it to appear on a WordPress page.

    I wrote a short post on how to get compact archives to work on a page.

    Much thanks :)!

  • 9. Rob  |  February 9th, 2008 at 9:07 pm

    jess: Thanks! I’ll link to it somewhere.

  • 10. Was  |  March 7th, 2008 at 7:19 am

    That worked…
    thanks :)!

  • 11. manele noi  |  March 7th, 2008 at 11:55 am

    Great plugin, I use it on my blog.

  • 12. Chikatze  |  March 19th, 2008 at 9:23 pm

    Thank you! Great plugin!

  • 13. Steven  |  March 27th, 2008 at 8:15 am

    Wicked. I started to write my own page template about a month ago to do exactly the same – no need to finish that one anymore with your great plugin!

  • 14. Jean  |  April 24th, 2008 at 12:13 pm

    Thank you. I love this plugin, its much nicer than anything else I have been able to find. It is much appreciated.

  • 15. donalyza  |  July 8th, 2008 at 5:49 pm

    hi like this plugin. Just wondering if there’s a way to exclude a particular category?

  • 16. Rob  |  July 10th, 2008 at 10:39 am

    donalyza: Sorry there isn’t a way (currently) to exclude a category.

  • 17. Пятигорец  |  July 19th, 2008 at 9:04 pm

    Nice plug, especially when a large number of records

  • 18. Links Breaker  |  August 4th, 2008 at 8:15 pm

    Congratulations Rob! I’ve tweaked Compact Archives, so that it always shows the first letter in uppercase, in the following way:

    1- I used the PHP function ucfirst()
    if ($month_has_posts) {
    $result .= ‘‘.ucfirst($month_abbrev).’ ‘;
    } else {
    $result .= ”.ucfirst($month_abbrev).’ ‘;

    2- I need to show the Archive of a specific category. Is this possible, using your plugin? How to?

    Thanks, Links

  • 19. Rob  |  August 5th, 2008 at 8:59 am

    Links Breaker: Strange, the code should already be showing the first letter in upper case without your tweak. Was it not?

    A few other people have asked for category specificity — it ‘just’ requires modifying the main SQL query so I’ll have a go.

  • 20. Rob  |  August 6th, 2008 at 3:34 pm

    Links Breaker: I take it back! It isn’t as easy as I thought it would be… Here’s the thing: it is easy to restrict the output to only show months with posts from the chosen categories but it is not easy to make the links point to pages which list a month’s archive only of the chosen categories.

    At least, there are several ways to do it but each involves filtering the archive query in a way that extends beyond the remit of this plugin. It involves making decisions that would vary from site to site.

    So back on hold for a bit. I am open to suggestions and ways to proceed.

  • 21. Tech Blog  |  October 12th, 2008 at 9:52 pm

    Great plugin.

    Works great on a custom page, thanks!
    Saved me loads of time 😉

  • 22. Kahotep  |  November 16th, 2008 at 3:20 pm

    Hi there. I installed your Compact Archives plugin on my wordpress blog and styled it using some CSS. I really love it. Just one question: At the moment I have the block version across the top of my blog, like so:

    2008: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    2009: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

    But when I get to 2009, I want to be able to hide the 2008 row of months using a
    tag i.e. a dropdown allowing you to select the year, which would then change the row of months to the year selected (and the posts in the main content area). How would I do this?

    Any help would be much appreciated… thanks in advance. 🙂


  • 23. Kahotep  |  November 16th, 2008 at 3:22 pm

    … i meant to say a
    <select onchange="set_Year(this);">
    tag for the dropdown thing…

  • 24. dyeflySpeerse  |  December 8th, 2008 at 8:09 am

    Hello How i can propagate images here ?
    I try upload it, but something wrong.

  • 25. Alex  |  December 12th, 2008 at 7:50 am

    Supported WP 2.7?….

  • 26. Tyler  |  December 30th, 2008 at 7:20 pm


    Your plugin looks fantastic, but I have one inquiry: Is it at all possible to set this up for weekly archives?



  • 27. Mtías  |  January 24th, 2009 at 2:29 am

    Hi Rob. I want to know if is possible to develop some function that allow to exclude certain categories. I’m not a code master so if you can help me on that, it will be really useful for me.

    Thanks in advance.

  • 28. oyun  |  March 10th, 2009 at 1:03 am

    thank you Supported WP 2.7 ???

  • 29. Ash  |  April 9th, 2009 at 9:24 am

    Every powerful plugin and should be used in wordpress. Does it works for all wordpress versions specially 2.7.1?

    Moreover, if i don’t display posts from multiple categories on my blog how can i hide them in my monthly archives too ?

  • 30. iddaa  |  April 22nd, 2009 at 12:52 pm

    “month names and abbreviations are chosen in accordance with the language locale (WPLANG) set in wp-config.php” –
    it does not work while in the configuration file, all is correct. And this problem is not just me – have to output only numbers

  • 31. medyum  |  July 9th, 2009 at 3:06 pm

    One thing though: non-standard characters in month names don’t go well (and break validation).
    I fixed this by surrounding the calls with utf8_encode but that might not work for everybody.
    Maybe you could just hint to this workaround if those funny characters show up.

  • 32. medyum  |  July 11th, 2010 at 12:10 pm

    I love how compact it is, but it would also like to see it as a widget.

    In any case – thanks for sharing!

    Medyum Niyazi