How to skin your WordPress theme

Share this on...

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? 😀

Share this on...

Published by Eric Brooks

Web & Graphic Designer, Blogger, Musician, Evil Clown. I also code websites and promote people for a living. Still kind of a jerk, though. Approach with food. PS: Don't listen to Snopes. I am REAL NEWS, and I don't let my crush on Tulsi Gabbard interfere with my objective reporting. So NYAH!

2 replies on “How to skin your WordPress theme”

  1. Well you did have a couple of posts where I would have left you a comment, but I couldn’t!

    phhhhhhtttttt !!!! 😀

    Nice job babe!

Comments are closed.