This is part of a series of posts on how to create a WordPress theme. See also: Step 1 and Useful Resources.

Now we have the basic layout (we could have spent a lot of time at this point working on the design), let’s turn it into a very simple Worpdress theme: an index.php file and a stylesheet, style.css.

What to put in each file:

style.css contains all the stylesheet information, I have cut and pasted this over from my original layout (see the code in the heaader). There’s also a few lines put up at the top which are used to describe your theme:

Theme Name: Summer 2007
Theme URI:
Description: A simple two-column theme.
Version: 1
Author: Rachel Cunliffe
body { text-align: center; font: normal 76% Verdana, Helvetica, sans-serif;}
#container { width: 890px; text-align: left; margin: 0 auto; }
#header { }
#menu { margin-bottom: 20px; }
#content { width: 490px; float: left; margin-bottom: 20px;}
#sidebar { width: 370px; float: right; }
#footer { clear: both; }
#header, #menu, #content, #sidebar, #footer { padding: 5px; border: 1px solid #000; }

index.php is very similar to my original layout but with some minimal WordPress code.

Use the WordPress manual tag reference list, add tags to the HTML. I have used the following:

  • <?php bloginfo('name');?> in the title of the page, pulled in from your WordPress » Options » General settings.
    Why use code when you can just write the title in there? Later on, you may want different pages to have different titles and code can do this for you. Also, if you want to change your blog’s name later on, you can change it via the options page and not muck around in templates. Also, if you want to share your theme with others, you don’t want your blog name turning up everywhere!
  • <?php bloginfo('stylesheet_url'); ?> is used for the stylesheet, instead of hard-coding in the location of it. If you share your theme with others, or move your blog, this will change automatically for you.
  • <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endwhile; else : endif; ?>

    This code tells WordPress to display the title and content of the posts. It’s a very simple “WordPress loop”. WordPress will figure out what to show on different pages of the site as long as you have one of these loops in there. Basically, you can ignore understanding code in the first part of the loop and the last part – just know it needs to be there. The bit in the middle is where you get WordPress to display your content. For my simple loop it is:

    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>

    In other words I use two WordPress tags, the title and the content. There are plenty of other tags on the tag reference list that you can use in here.

Here’s the index.php template:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”

<html xmlns=””>
<title><?php bloginfo(‘name’); ?></title>
<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />


<div id=”container”>
<div id=”header”>

<div id=”menu”>
<div id=”content”>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; else : endif; ?>
<div id=”sidebar”>
<div id=”footer”>

Download the zipped theme:

Install the theme (preferably on a test site since it’s a teaching template): unzip and drop the folder into your wp-content/themes/ folder.

Next step: Expanding out the template to have more functionality (e.g. linking to each post and having comments).

Get actionable tips to grow your website

Thoughtful weekly insights (no hype!) on improving your website