for the obsessive theme switchers

I’m prepetually unsatisfied by themes. it’s not the theme authors’ fault, i’m just restless. alex king pointed to more advice: From Install to Pimped Out that sounds like the advice i found when i started using wordpress. but for anyone who does, or might, change themes, it’s wrong.

when you’re talking about meta tags, or feedburner RSS feeds, or custom title tags, you’re talking about things you don’t want to break when you change themes. and there’s no reason for them to. this is how i do it: i wrote a plugin.

Gasp! Shock! horror!
not really. if you can handle everything in the post above, you can handle this plugin. here’s how it starts:

<?php
/*
Plugin Name: archGFX Functions
Plugin URI: http://archgfx.net/
Description: all the things that i hack into themes, now they have their own file
Version: 1.0
Author: SunBurntKamel
Author URI: http://archgfx.net/
*/

you need to have a name, the rest of it’s optional.

so, all that fun stuff that you want to add to the head of your blog? dump it into a function:

function archGFX_head() { ?>
<META NAME="Description" CONTENT="archGFX is the brand name used by Adam Freetly. This portfolio represents personal and collaborative work." />
<meta name="keywords" content="adam freetly, architecture, blog, portfolio, design, rendering" />
<META NAME="geo.position" CONTENT="41.92;-87.70" />
<META name="geo.region" content="US-IL" />
<META name="geo.placename" content="chicago" />
<link rel="shortcut icon" href="http://www.archgfx.net/images/blogrdfbg.jpg" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://feeds.feedburner.com/archGFX" />
<link rel="search" href="http://archgfx.net/opensearchdescription.xml" type="application/opensearchdescription+xml" title="archGFX" />
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-91088-3";
urchinTracker();
</script>
<?php }

obviously i have a few more things than average. google analytics scripts, geo tags, favicon, etc. you can call the function whatever you want, just remember it. now that we’ve got all our code, we need to insert it:

add_action('wp_head', 'archGFX_head');
?>

that’s it, save the file, activate your ‘plugin’, and you’re good to go. naturally, i do a few more things with this. i also handle my footer copyright notice the same way, with

add_action('wp_footer', 'archGFX_foot');

i add the mybloglog widget to my dashboard with
add_action('activity_box_end', 'archGFX_MBL');

and, i don’t have to worry about forgetting to add any of it next time i switch themes.  the only thing that i don’t put in the plugin is my title tags.  you can only have one of those.  so while i could add mine with a plugin, i’d have to delete the theme’s title manually.

Advertisements