The Thin Line: From Skin To Theme

You may have noticed that i really like The Sandbox. Andy suggested a possible path for it to become the default theme, which I think would be an excellent idea. Mainly because writing PHP is not my strong suit. CSS is closer to my skill set.

WordPress versions 1.2 and below used a templating system like the one andy proposed. The problem was, the classic theme had limitations. if you wanted to remove the sidebar on post pages, as kubrick does, you were out of luck. The Sandbox would fix that. The other development that helps make templating viable again was introduced in wordpress 2.0. Since 2.0 was introduced, wordpress loads functions.php of the current theme, if it exists. this means that a theme could use only style.css and functions.php, and have an enormous level of control.

Changes to The Sandbox

it’s been a while since andy added the sandbox branch, but it doesn’t seem to be making progress. so, while i can’t implement status: hidden, i can make a workable version of The Sandbox to test The Thin Line on.

It’s been stripped of it’s skins panel (as well as the skins subfolder), had the default skin set to none, and had status: hidden added to the theme information. I also moved wp_footer(); inside the #footer div, for even greater semantic justice so that information added to the footer can be styled more easily (scroll to the end).

Changes to The Thin Line

when i said that Themes could be built on style.css and functions.php, that’s only partly true. you could build a theme that way that only inserted a footer credit, and applied javascript to the head of the theme. to add an options panel, you’ll probably want to use theundersigned’s tutorial, or ozh’s theme toolkit. I’m using theundersigned’s tutorial, mainly because the PHP is simple enough for me to get the gist of what’s going on. Ozh’s toolkit does more, but requires me to take more on faith, and has previously caused problems on the theme viewer and

The first step to gluing The Thin Line to The Sandbox is this:


Theme Name: The Thin Line

Theme URI:

Version: 0.7

Description: Hand on mouth, the game goes on

Author: Sunburntkamel

Author URI:

Template: Sandbox


That’s my entire style.css. it doesn’t need to have anything else. I’ll be using style.php for all the style information. The important part is the last line, which tells wordpress to use the template files (index.php, single.php, etc) from ‘sandbox’ to handle the content. Style.php will be loaded on top of the existing sandbox CSS, which is why we set the sandbox skin to ‘none’.


I was going to re-use the sandbox’ “skins” submenu at first, but that would require digging into the function, and renaming all the variables to use theundersigned’s $shortname converntion, and including it in the thin line, rather than the sandbox. That requires redistributing more code, which isn’t my goal. so i used theundersigned’s tutorial to make a dropdown list.

corrosponding to the dropdown list is this section of style.php, which performs roughly the same task as the skins page:

<?php if ($thethinline_layout_style = "3c-b") { ?>

@import url('skins/3c-b.css');

<?php } else if ($thethinline_layout_style = "3c-l") { ?>

@import url('skins/3c-l.css');

<?php } else if ($thethinline_layout_style = "3c-r") { ?>

@import url('skins/3c-r.css');

<?php } else if ($thethinline_layout_style = "2c-l") { ?>

@import url('skins/2c-l.css');

<?php } else if ($thethinline_layout_style = "2c-r") { ?>

@import url('skins/2c-r.css');

<?php } else { /* 1c-r */ ?>

@import url('skins/1c-b.css');

<?php } ?>

after that, style.php is just the remainder of the original thethinline.css. The advantage of styling in a PHP fileis that you can use variables, wordpress conditionals, and other assorted tricks.


Adding functionality to The Thin Line via functions.php is a little more like writing a plugin than like writing a theme. I’m using add_action(); hooks to add to both the header and footer of the theme. I could also add and remove widgets, although i don’t need to mess with the basic widget formatting, because that’s handled by functions.php in The Sandbox. Theundersigned’s tutorial needs a minor correction first, though. at the end of functions.php, I changed <?php bloginfo('template_directory'); ?> to <?php bloginfo('stylesheet_directory'); ?>. For most themes, those hooks point to the same file. This is the first time the difference matters to a theme.

Updated Footer

This is the new footer for The Thin Line. I added an image and link to The Thin Line homepage, as well as a section for users to add their own copyright notice/pithy slogan/whathaveyou (another trick i stole from scott). This is purely PHP, but it’s not scary. Just make the end of theundersigned’s functions.php look like this:

function mytheme_wp_footer() {/* Places credit link in the footer */ ?>

<span id="skin-link">

<a href="" title="Theme by SunBurntKamel">

<img src="<?php bloginfo('stylesheet_directory'); ?>/thethinline/ttlogo.jpg" alt="The Thin Line" title="The Thin Line" /></a></span> <br />

<p class="annotation"><small><?php echo $thethinline_footer_text ?></small></p><?php }

add_action('wp_head', 'mytheme_wp_head');

add_action('admin_menu', 'mytheme_add_admin');

add_action('wp_footer', 'mytheme_wp_footer');


That’s actually probably easier than creditting yourself in footer.php I could (and may possibly) also use this function to add, say, siFR to the theme as well. Someone who didn’t ph34r javascript the way i do might add livesearch to a sandbox based theme.

The End

My point in writing all of this is to show that the idea of writing a new theme every time is overkill. Template files themselves don’t vary a lot. Most of the functionality and variation happens in javascript and CSS. those can both be handled by only a couple of files. If theme authors could depend on the sandbox being in every wordpress distribution, It would make it easier for them, as well as for casual users who just want to change something small about a theme. It’s a lot easier to find the thing to change when there are only 3 files in the Theme Editor panel of the dashboard.

theme contents

I was going to include The Thin Line with this, but i’m having a little difficulty making everything style the way it was before, and some of the variables i’ve created with theundersigned’s tutorial aren’t properly sticking, despite showing up correctly in my database.

Bookmark This:

add to :: Digg it :: add to ma.gnolia :: Stumble It! :: seed the vine :: TailRank


One thought on “The Thin Line: From Skin To Theme

Comments are closed.