Compact Archive: WordPress Plugin

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 displays the monthly archive of posts in two 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

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.

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

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.

Feedback

If you try this plugin leave a comment here to let me know how you get on.

10 replies on “Compact Archive: WordPress Plugin”

Comments are closed.