Compact Archives

Caveat

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

Description

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

Instructions

  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='

  • ', $after='

 

‘);

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.

Version

  • Compact Archive v1.0.6 adds the numeric month display.
  • Compact Archive v1.0.5 fixes a problem showing localised dates with accented characters.
  • Compact Archive v1.0.4 makes use of the Plugin Output Cache if it is available.
  • Compact Archive v1.0.3 fixes a small problem with undated posts.
  • Compact Archive v1.0.1 still works with previous versions of WordPress but takes advantage of new features of WordPress 2.1.
  • Compact Archive v1.0.0 is the original plugin.

Acknowledgements

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

106 replies on “Compact Archives”

  1. 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

    tom

  2. Hi,

    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.

  3. 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 🙂

    -K

  4. 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 http://www.skymonkey.org & if you want the amended source let me know and I’ll email it to you.

    Thanks again!

  5. 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

  6. 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.

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

  8. 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. 🙂

    -kah

  9. 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.

  10. 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 ?

  11. “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

  12. 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.

Comments are closed.