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. Rirath  |  January 15th, 2007 at 8:20 pm

    Excellent idea. I’ve never really had much use for navigating by date, aside from showing visitors the blog has a long history, but this is a great and compact way to do both.

  • 2. Rob  |  January 15th, 2007 at 11:14 pm

    Rirath: thank you!

  • 3. Tato  |  January 16th, 2007 at 11:33 pm

    Great plugin! Thanx a lot for coding it!

  • 4. Debra  |  January 23rd, 2007 at 5:08 am

    It took me a little while to implement this plug-in between WP 2.0 whatever and using K2, but I was able to add it, and I love it!

    Previously I was using a plug-in that created a drop-down menu out of archives, but upon upgrading WP, that plug-in no longer functioned.

    Since I’ve got over 3 years of archives, I’m glad to have a compact way to list them that doesn’t scroll down my page for miles. :)

  • 5. Rob  |  January 23rd, 2007 at 10:08 pm

    Version 1.0.1 updates the plugin to take advantage of new features in WordPress 2.1.

  • 6. Michiel Maandag  |  February 2nd, 2007 at 3:20 pm

    How do you get the list of blog items below the
    “2006: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec” line as you have it on your archieve page?

    Do I need to change something in the plugin to make that happen?

    Many thanks for the reply! Cheers, Michiel

  • 7. Rob  |  February 2nd, 2007 at 3:23 pm

    Michiel Maandag: That is using the archive code provided in the Blix theme I use (slightly modifed for speed).

  • 8. CDC  |  February 2nd, 2007 at 11:38 pm

    Awesome plugin. Especially nice considering I’ve got stuff going back to 2001.

  • 9. turtlegirl76  |  February 4th, 2007 at 5:01 pm

    I’ve got it working (thank you SO much for making this!) but I have one extra line of archives, with nothing in it, below my last year of archives, listed as “0” with no entries for any of the months. How do I get rid of that?

  • 10. Rob  |  February 4th, 2007 at 5:26 pm

    turtlegirl76: That’s very odd! I’ll have a look and see if I can discover what on earth could be causing it.

  • 11. Rob  |  February 4th, 2007 at 5:42 pm

    turtlegirl76: Let me know whether v1.0.3 fixes the problem. I think you may have a post without a proper date for some reason… anyway this should filter it out.

  • 12. turtlegirl76  |  February 4th, 2007 at 8:32 pm

    Thank you so much! That did fix it!

    I blame blogger. It must have been something from when I imported my old posts.

  • 13. Rob  |  February 11th, 2007 at 3:42 pm

    I have just updated Compact Archive to use my new Plugin Output Cache plugin. If the cache is available it makes the archive much more efficient.

  • 14. Julia  |  February 23rd, 2007 at 2:18 pm

    Wonderful, your plugin makes the archives nice and clean.
    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.

  • 15. Rob  |  February 23rd, 2007 at 3:49 pm

    Julia: Thanks for your comments. I am dealing with a number of language-related issues at present so this just adds one more! I’m certainly learning…

  • 16. Rob  |  February 23rd, 2007 at 4:20 pm

    Julia: Version 1.0.5 contains the utf8 fix as standard so you can remove the extra code in your template. Thanks!

  • 17. furiousball  |  March 8th, 2007 at 9:23 pm

    Love this plug-in, my blog goes back to 2002 and this really helped tidy up my sidebar. Thanks again!

  • 18. ikari  |  March 8th, 2007 at 11:14 pm

    I have modified this plugin a bit to suit my needs, but since I havent “officially” moved to WordPress yet – I’m sending you my version (1.1.0) via e-mail.

  • 19. ikari  |  March 12th, 2007 at 10:45 pm

    Moved and using it :)
    The version I’ve sent has an obvious error, I hope you got it by now. It didnt pass the parameters from one function to another.

  • 20. John  |  March 15th, 2007 at 6:53 pm

    Hi. How do I get this plugin to work inside a wordpress page? thanks.

  • 21. Rob  |  March 15th, 2007 at 9:18 pm

    John: You would need to create a page template with a call to the plugin embedded in it and then create a page based on that template. My own archives page is based on the following template:

    Template Name: archives
    <?php get_header(); ?>
    <!-- content ................................. -->
    <div id="content" class="archive">
    	<h2>Archive &ndash; All Entries</h2>
    	<ul class="postspermonth">
    		<?php if (function_exists('compact_archive')) compact_archive('block'); ?>
    	<?php if (function_exists('blix_archive')) blix_archive(); ?>
    </div> <!-- /content -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

  • 22. Daryl W.T. Lau  |  March 16th, 2007 at 11:28 pm

    Hi there… I’m also facing problem getting it to work on a WP page. Do I need to insert the codes shown just above to the existing ‘page.php’ in my template folder?

    Can you kindly guide me through the steps cos I am a total noob in codings. LOL!

    Thanks in advance!

  • 23. Rob  |  March 17th, 2007 at 7:08 am

    You need to create a file in your template directory alongside ‘page.php’ called ‘archives.php’ or something. Copy the code I gave above to fill that file. Make sure there are no extra spaces or anything above or below the code.

    Then inside the WP admin use Write Page to make a more or less blank page with whatever title you want. Make sure you base the page on your new template.

    I hope that works for you.

  • 24. Gazrang  |  March 20th, 2007 at 5:54 pm

    Hi. Rob.
    I installed your compact archive to my new-born blog.
    It looks quite good on minial theme.

    I content with this appearance but I want to make this abbr(ex Jan, Feb) to arabic number(1,2,3..). If I never edit the wp-config.php(WPLANG status), ‘initial’ style look similar that I hope. But it is not bad when the digit go over 10. It looks like following:
    1 2 3 4 5 6 7 8 9 1 1 1

    Can I fix this problem?

  • 25. Rob  |  March 20th, 2007 at 6:24 pm

    Gazrang: Try editing the ‘block’ output code to replace %b with %m, i.e., $month_abbrev = strftime("%m", $dummydate);

  • 26. Gazrang  |  March 20th, 2007 at 7:55 pm

    Wow. Thank you for your reply. :)
    That worked seemlessly..

  • 27. Gazrang  |  March 21st, 2007 at 1:00 am

    Using compact archive, I made archives page on sidebar.

    On click the archive menu, page shows ‘blocks’ of whole year one line. But it never shows the whole post-title-list like your archive.

    I made Archive page using your template above, and modified to fit my theme.

  • 28. vincent  |  April 4th, 2007 at 5:45 am

    Any idea how we would make this a widget? I’d like to use this on my wordpressMU install, but dont want to have to have users add it to the theme code.

  • 29. Rob  |  April 4th, 2007 at 7:54 am

    vincent: I believe making it a widget would pose no insuperable difficulties — it’s just something I’ve only glanced at a few time rather than thinking seriously about. I’ll have another look…

  • 30. Scudfish  |  April 12th, 2007 at 11:02 pm


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

    In any case – thanks for sharing!


  • 31. Rob  |  April 13th, 2007 at 7:10 am

    Scudfish: Maybe I’ll take this as an opportunity to learn about widgets.

  • 32. Jonathan  |  April 22nd, 2007 at 1:13 am

    Thanks for releasing this very nice plugin. I just added it to my blog, and it looks great.

    Nice job!

  • 33. dawn  |  May 13th, 2007 at 7:25 pm

    thanks so much! lost my old archives with the 2.1 upgrade but this is working beautifully and was so easy to set up!

  • 34. El  |  May 14th, 2007 at 7:20 am

    This is a great way to display a monthly archive. I love it!

  • 35. Enzo Santagata  |  May 17th, 2007 at 12:03 pm

    Great plugin, I use it on my blog.

  • 36. Rony  |  May 23rd, 2007 at 3:15 pm

    I Cannt Find To Do Archive In A New Page
    I Want It To Open It In A New Page. The Archive Is In To The Header. How Can I Do This

  • 37. Slowload  |  June 2nd, 2007 at 1:10 pm

    Your plugin slowed down the loading of any page on my blog from a load time in seconds of 0.72 seconds without the plugin TO 4.44 seconds with the plugin activated! :(

    I’m using WP2.0 by the way, is that the reason or is it a bug you might need to fix?

    I used this code:

  • 38. Rob  |  June 2nd, 2007 at 2:29 pm

    Slowload: I hope you mean it slowed down the pages on which it appears… That doesn’t surprise me since the plugin does a lot of work putting together the archive of all your posts. You can make it a lot more efficiient by install my Plugin Output Cache which will keep a copy of the archive and only regenerate it when necessary.

    If you mean that the plugin even slows down pages on which it doesn’t appear … that would be a serious problem.

  • 39. Slowload  |  June 2nd, 2007 at 3:18 pm

    Hi Rob, thanks a million for the tip! That fixed any slowdown that was occurring, it just wasn’t being cached heh. Thanks again for the great plugins, I’m going to try out more of yours now.

  • 40. Dominic  |  June 11th, 2007 at 1:22 pm

    cool stuff!! just a question though.. is it possible to swap the months Jan Feb Mar into numbers in mm format as in.. 01 02 030 4.. 12 ??

    Any help or advise will b greatly appreciated!!


  • 41. Rob  |  June 11th, 2007 at 2:44 pm

    Dominic: Check out version 1.0.6!

  • 42. Marty  |  June 16th, 2007 at 2:52 am

    I was wondering if this will work as a Text Widget? I tried adding

    <?php compact_archive($style='initial'); ?>

    to my theme, but nothing is being output…

    — Marty

  • 43. Rob  |  June 16th, 2007 at 7:58 am

    Marty: I’m afraid I haven’t mastered widgets yet … but what you need to try is
    <?php compact_archive('initial'); ?>
    Let me know if this helps.

  • 44. Marty  |  June 16th, 2007 at 4:17 pm

    Thanks – I couldn’t get it to work as a widget, but I was able to put it directly into the sidebar and get it to work.

  • 45. Rob  |  June 17th, 2007 at 9:41 am

    Marty: Glad to hear.

  • 46. james  |  June 22nd, 2007 at 5:14 am

    i’ve been trying to get the formatting right, but i’m having no luck.

    i have the following in my stylesheet to change the text color to match the background for all of the “emptymonths” but it doesn’t appear to be working.

    .emptymonth {
    color: <?php echo $bottombgcolor; ?>;

    the only complication i have is i am using a modified RoundFlow theme which uses php to set color options in the css from the WordPress admin.

    Any help to work round this greatly appreciated

  • 47. Rob  |  June 22nd, 2007 at 8:42 am

    james: I don’t know the theme you mention but the code looks OK to me. Could it be a caching issue?

  • 48. Jon  |  August 6th, 2007 at 4:12 am

    Thank you very much. I love this style of list and your plugin makes it a cinch.

  • 49. Jorge Hernndez  |  August 23rd, 2007 at 10:13 pm

    Thank you, it works, but I have the following problem: in the site I’m developing, months are displayed in small letter:

    # 2007: ene feb mar abr may jun jul ago sep oct nov dic

    I would like to display them in big letter

    I’ll really appreciate your help!

  • 50. Stacy  |  August 24th, 2007 at 5:17 pm

    I uploaded and set this up on a page today, and received a rather nasty looking error…any thoughts? I created an archives.php file based on the info you had above, then created a new page with the following code:

    Here’s the error, which is also displayed at the top of the page…if you want to take a peek on my site. Thanks.

    Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /home/snarlyn6/public_html/wp-content/themes/petlover-10/archives.php on line 7

    Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /home/snarlyn6/public_html/wp-content/themes/petlover-10/archives.php on line 10
    {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \f0\fs24 \cf0 \ \

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

    Oops…here’s the code on the page:

  • 52. 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


  • 53. 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.

  • 54. 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 :)


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

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


  • 56. 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!

  • 57. 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.

  • 58. 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 :)!

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

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

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

    That worked…
    thanks :)!

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

    Great plugin, I use it on my blog.

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

    Thank you! Great plugin!

  • 63. 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!

  • 64. 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.

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

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

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

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

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

    Nice plug, especially when a large number of records

  • 68. 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

  • 69. 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.

  • 70. 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.

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

    Great plugin.

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

  • 72. 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. :)


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

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

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

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

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

    Supported WP 2.7?….

  • 76. 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?



  • 77. 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.

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

    thank you Supported WP 2.7 ???

  • 79. 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 ?

  • 80. 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

  • 81. 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.

  • 82. 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