Compact Archive: WordPress Plugin
October 29th, 2006
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
- Upload the whole plugin folder (Compact_Archive) to your /wp-content/plugins/ directory.
- Go to your Admin|Plugins page and activate Compact Archive.
- Put
<?php compact_archive(); ?>at the place in your template where you want it to appear, e.g., in your sidebar:
<ul> <?php compact_archive(); ?> </ul> - 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='<li>', $after='</li>');
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.
<ul>
<?php compact_archive(); ?>
</ul>
The year link at the start of each line is wrapped in <strong></strong> and months with no posts are wrapped in <span class="emptymonth"></span> 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.
Entry Filed under: Programming, WP Plugins
Tagged as:
4 Comments
1. Brian Jarrett | December 20th, 2006 at 2:35 am
Great plug-in! It really shrunk down the size of my archives listing. Thanks for writing it and releasing it.
2. David | January 10th, 2007 at 4:14 am
Thanks for this nifty plugin! It works great and looks good.
3. Rob | January 10th, 2007 at 7:53 am
4. Rob | January 14th, 2007 at 5:58 pm
Comments are now closed for this post.