Smart Archives Reloaded

Smart Archives Reloaded: Version 2.0

Flexible post selection

You can select exactly which posts you want to display. The smart_archives() template tag now takes a second parameter, which accepts most of the arguments that query_posts() accepts.

Here is the “laziest” way to use it:

<?php smart_archives('', $GLOBALS['query_string']); ?>

If you put that code in author.php, for example, it will display the list of posts by the current author. If you put it in tag.php, it will list the posts in the current tag etc.

You can also make it display the same set of posts, no matter where it’s placed:

<?php smart_archives('', array( 'author_name' => 'scribu' ) ); ?>

The possibilities are endless.

Fewer queries

With the previous version, generating the archive page on this site required around 900 database queries. Now it’s down to 300.

No more buggy caching

Older versions of the plugin stored the generated HTML in a text file, instead of generating it on each page load. Unfortunately, this relied on two rather unreliable things: file permissions and wp-cron. Thus, it was the biggest source of problems for users. So I decided to remove file caching completely.

If you want caching back, the best solution is to use a dedicated plugin, such as WP Super Cache. It will make your entire site load much faster.

Smart Archives Reloaded: Advanced Tweaking

Since version 1.9, you can make modifications to the plugin output, without having to modify the plugin code. This way, your tweaks won’t be lost when you upgrade the plugin.

Custom styling

If you want to customize the appearance of the archives using your own CSS, here’s how you do it:

  1. Add this code to your theme’s functions.php file:

    add_filter(‘smart_archives_load_default_styles’, ‘__return_false’);

  2. Copy everything from smart-archives-reloaded/inc/styles.dev.css into your theme’s style.css file.
  3. Change the CSS in your theme’s style.css file, as needed.

Custom markup

If you want to go one step further and change the generated HTML markup, you can do that too (understanding of object inheritance is required).

First, take a look at the SAR_Generator class (in smart-archives-reloaded/generator.php).

In your theme’s functions.php file, you can extend that class, like so:

class SAR_Custom_Generator extends SAR_Generator {

	protected function generate_fancy() {
		// your custom code here
	}

	protected function generate_block() {
		// more of your custom code here
	}

	...
}

Then, all you have to do is add the ‘generator’ argument to the template tag:

<?php smart_archives('generator=SAR_Custom_Generator'); ?>

Smart Archives Reloaded: Version 1.9

Lots of goodies in this release, based on the feedback and requests I got from you guys (and gals).

The Menu Format

First off, there’s a new format called “menu”. It’s basically the year and month menu from the fancy format, but without the post list. It’s meant to be displayed on year and month based archives, to aid navigation.

Usually, those archives are handled by the archive.php template in your theme, so that’s where you should use it:

<?php smart_archives('format=menu'); ?>

New arguments

There are also two new arguments:

month_format – can be one of ‘numeric’, ‘short’ and ‘long’

posts_per_month – set the number of posts displayed per month; by default, all posts are displayed.

<?php smart_archives('posts_per_month=25'); ?>

Finally, you can now customize the look and feel more easily. See Advanced Tweaking.

Smart Archives Reloaded: Version 1.8

Previous versions of this plugin allowed only a single type of archive, controlled entirely from the settings page.

Version 1.8 is a lot more developer friendly: any options set on the settings page can be overwritten:

In your theme, you can now write:

<?php smart_archives('format=list&#038;exclude_cat=123,543'); ?>

This works for the shortcode too. In any post or page, just write:

[smart_archives format=list exclude_cat=123,543]

What’s neat about this is that you can have more than one archive, or have the archive display differently in different parts of your site.

Smart Archives Reloaded: Version 1.7

This release was basically written by Simon Pritchard. I just added the finishing touches.

Fancy new style

Version 1.7 adds an integrated multi-level navigation UI to the archives, perfect for sites with a large number of posts.

Fancy archive on the default theme

See a live example.

New formatting tags

First, you have %category_link% and %category%, which will output a category list for each post.

Secondly, you have %date%, wich will print out the publish date of each post. There is an additional field where you can customize the date format.

If you like the new features, go thank Simon for his effort.

Smart Archives Reloaded: Version 1.6

In version 1.6 you can better control how each post is displayed in the list:

New setting

Also, the admin page has been rearanged in a more logical order: general settings and specific settings.

Smart Archives Reloaded: Version 1.5

This version adds a new setting, namely the ability to display the month links in the block as numbers from 01 to 12.

The plugin is now fully translatable.

Finally, the cache file is now located in the uploads directory, so that you don’t have to mess with file permissions anymore.

Smart Archives Reloaded: Version 1.4

Instead of updating the cache at a regular interval, the plugin now updates when a post is published or deleted.

Also, an issue with accents should be fixed.

Finally, some optimizations were also baked in.

PHP5 is required

Smart Archives Reloaded: Version 1.3

This version adds a new feature and has several bugfixes and improvements:

PHP5 is required.

Smart Archives Reloaded: Version 1.2

I have been using Smart Archives for some time and I really liked it, but version 2.0 wasn’t up to snuff, in my opinion. So I decided to improve it, until I ended up with this plugin:

Version history