How to skin your WordPress theme

I have comments again, YAY ME!
Not that anyone leaves comments… buuut… 🙁

When I upgraded to WordPress2, I had a hard time making a flexible theme, so I ditched that idea and decided to parse the code myself (like I did with the original WordPress). The problem? My individual posts no longer had comments. (UH OH!)

So how do you make a theme that is flexible with your Domesticat-like skinning abilities?

You make a theme inside a theme, of course. 😀

  1. Open your wp-content/themes/[yourtheme]/header.php file
  2. Put in your skinning information in the header like you usually do.
  3. Open your wp-content/themes/[yourtheme]/footer.php file
  4. Hard code the variable information that you need, particularly this part…
<?php
$total_skins = 3;
$default_skin = 3;
 

if (isset($_REQUEST[‘newskin’])) {
$newskin=(int)$_REQUEST[‘newskin’];
if ( ($newskin<1) OR ($newskin>$total_skins) ) $newskin=$default_skin;
$skin=$newskin;
} elseif (isset($_COOKIE[‘skin’]))
$newskin = $_COOKIE[‘skin’];
elseif (isset($_REQUEST[‘newskin’])) {
$newskin=(int)$skin;
if ( ($newskin<1) OR ($newskin>$total_skins) ) $newskin=$default_skin;
} else $newskin=$default_skin;
include(‘/home/yoursite/public_html/skins/$skin/footer.php’);
?>
</body>
</html>

That part is the one that tells your theme what skin the reader has selected using. (It’s slightly changed from the Domesticat version as you can’t set cookies in the footer.).

For whatever reason, WordPress kills all your variables right after it does its thing. You need to re-code your variables in the footer as well.

See what I mean? 😀

Proudly powered by WordPress
Creative Commons License
EricBrooks.Com® is licensed under a Creative Commons License.

Disclaimer: The views expressed herein are solely those of Eric Brooks. They do not necessarily reflect those of his employers, friends, contacts, family, or even his pets (though my cat, Puddy, seems to agree with me on many key issues.). In accordance to my terms of use, you hereby acknowledge my right to psychoanalyze you, practice accupuncture, and mock you incessantly with every visit. As the user, you also acknowledge that the author has been legally declared a "Problem Adult" by the Commonwealth of Pennsylvania, and is therefore not responsible for any of his actions.


Connect