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. 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. 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. ๐Ÿ™‚

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

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

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

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

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

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

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

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

    
    <?php
    /*
    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'); ?>
    	</ul>
    
    	<?php if (function_exists('blix_archive')) blix_archive(); ?>
    
    </div> <!-- /content -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    

  11. 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!
    Daryl

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

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

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

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

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

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

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

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

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

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

    =)

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

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

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

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

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

Comments are closed.