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:
  2. add_filter('smart_archives_load_default_styles', create_function('', 'return false;'));
  3. Copy everything from smart-archives-reloaded/inc/styles.dev.css into your theme’s style.css file.
  4. 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:

smart_archives_load_default_generator();
 
class SAR_Custom_Generator extends SAR_Generator {
	protected static function generate_fancy() {
		// your custom code here
	}
 
	protected static 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'); ?>

Comments (5)

  • Simon says:

    Hey Scribu, This is awesome! I’d been wondering about customisations as I always make a bunch of stylistic changes to the Fancy archive that get lost whenever the plugin is updated… glad to see you’re way ahead of me! ;-) I’ll update the Archive on http://www.conceptfusion.co.nz shortly so the demo link is current.

    Cheers buddy.

    • shawn says:

      I just saw your archives page and it’s spectacular. Are you willing to share the mods it took to accomplish this?

      I searched your site high n low for a contact form but found none, so here’s hoping that you stumble upon my comment here.

      • scribu says:

        Hello shawn,

        I don’t use any modifications to the plugin to display the archives on this site. I’m just using the ‘both’ format.

        Regarding the contact form, you should be using the support forums, or send me an email to scribu@gmail.com if you’re interested in paid work.

  • Bowzer says:

    Is it possible to expand upon the fancy style where, instead of just having the post title displayed upon clicking of a year/month, you could display the entire post loop?

    I’m guessing it wouldn’t be as simple as slapping it into one of the files would it? :P