Smart Archives for WordPress
Get the source (v1.9.2; for WP v2.3+)
Get the source (v1.9; for WP v2.1-2.2)
Get the source (v1.5; last version released for WP v2.0 and below)
· changelog from v1.9.1
· changelog from v1.9
· changelog from v1.6
· changelog from v1.5
· changelog from v1.2
· changelog from v1.12
· changelog from v1.1
· changelog from v1.01
· changelog from v1.0
Smart Archives is a rather simple WordPress plugin that will allow you to display your archives in a much "cleaner" format. You can see it in action on my archives page. You'll notice that everything on the page is hyperlinked (years, months, posts) and that all of the respective links are future-proofed.
Installation and Implementation
- Place the smartarchives.phps file into your /wp-content/plugins/ directory.
- Change the file extension from ".phps" to ".php".
- Activate the plugin from the WordPress admin panel.
- If you use WordPress' "Pages" feature, see the notes below.
- Call the Smart Archives function like so:
<?php smartArchives('type','category ID'); ?>
"Type" is one of three values: block, list, or both. "Block" produces the block of years and months,1 "list" generates a reverse chronological list of your posts, including links to monthly archives, and "both" gives you the block and the list.
"Category ID" is simply the number of the category you want to exclude. If you want to exclude more than one category, simply put a space between them. Keep in mind that the "block" doesn't exclude categories. If you call the function with no arguments it will default to "both" and will exclude no categories. Some examples follow -- each is a proper invocation of the plugin.
<?php smartArchives('block','14'); ?>
<?php smartArchives('list',''); ?>
<?php smartArchives('',''); ?>
<?php smartArchives('both','14 20 1'); ?>
Archives without using WordPress' Pages
Please see this post.
A Couple Notes About WordPress' Pages
Formatting
Some people have been complaining that their formatting doesn't look like mine and that they are seeing linebreaks in weird places. I think the problem lies in the way the Pages feature formats the webpage. I don't use the Pages feature and so all of the linebreaks I stuck into the PHP code to make the HTML source "prettier," do just that. However, if you do use the Pages feature, you might want to remove the linebreaks ("\n") that are in the plugin code, because I think that Pages converts them to HTML (i.e., you end up with actual <p> and <br /> tags) and thus the page is ultimately rendered 'wrong.'
Using PHP
Apparently, if you want to run PHP code from within a WP Page you have to install a plugin to enable this "feature" (crazy, huh? I agree). That said, you can find the PHP Exec plugin here.
NOTE: I'm told that PHP Exec will not work in WP 2.0, but I'm also told that Exec-PHP works just fine.
Support
Hopefully you won't experience any problems, but feel free to e-mail me if you do.
-
Empty months are included (to balance the block), but are not hyperlinked. If you'd like to change the text color of these months (as I do on my archives page), you simply need to define a CSS class called "emptymonth" in your stylesheet. ↑