Create Your Own Template

Creating your own WordPress template is not as complicated as you may think. A lot of people suggest to use the default template and modify that. Personally I disagree. If you’re capable of writing your own HTML markup and CSS then all you need to know are the template tags and the wordpress loop. The only theme file I would recommend copying is the comments.php file, and I’d recommend using the Classic theme’s file, not the default one.

The Design and Markup

You can create the design however you want. Work out how you want the main elements of your blog to be (posts, category list, pages, archives list if you want it, comments etc). Take your design and, ignoring any theme for the time being, code your design up into HTML and CSS. The only thing to bear in mind with your markup is the following:

  • Pages, categories, Archives and Links are output by default as unordered lists. You can change this but it’s probably a good idea to keep them as lists.
  • Whilst it’s not essential, it’s usually a good idea to have a div around each post.
  • Your search input box needs the name and id as ‘s’, however a method of get or post can be used.

Break It Up

You can split your new page up into at least 3 maybe 4 sections. You have your header, containing the generic top content shown on every page, footer, the generic bottom content on every page, your sidebar, if it doesn’t/cannot fit into the header or footer, and the main index page that contains everything which doesn’t fit into these files. Each of these files must be called header.php, footer.php and sidebar.php and index.php.


In your index.php file you need to insert the following tags inside PHP tags:

Put this where you’ve removed the header section.
Put this where you’ve removed the footer section.
If relevant, put this where the sidebar/menu content was.

This will then set up the index file to pull in the header, sidebar and footer in the relevant places.

Around your post we need to add the loop code. Right before the post starts (eg. the opening div tag that surrounds the post), insert the code

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Then after your post markup close the loop using

<?php endwhile; endif; ?>

You will then want to add the following tags to help construct the dynamic post:

This echos out the full permalink of the post, used in the link around the post title.
This echos out the post title.
This creates a comma separated list of all the categories that the post has been added to.
Use this or the_excerpt() to display content from the post.
comments_popup_link(‘No Comments’, ‘1 Comment’, ‘% Comments’)
Displays the number of comments received on that post. You can change the parameter content to suit your site, just keep them in the same order and use the percentage sign to get the X comments.

There are also plenty of other tags you may want to use. A couple of more popular ones are

This will echo out the ID of the current post.
Echos out the date the post was written.
Echos out the time the post was written.
Echos out the name of the author of the post (usually linked to their own author page)

If your design is quite simple and your single post page is virtually identical to the front page then you may want to just have the index.php theme file power both pages. If so then you’ll also need to add the following tag just before the closing loop code that you added earlier:

<?php comments_template(); ?>

This will then pull in the comments.php file, which as mentioned earlier, I recommend you just copy the comment.php theme file from the Classic theme, and we can look at modifying that later.

Define Your Theme

To define your theme and make WordPress recognise it, you need to add the following to the top of your CSS file (which you need to call style.css).

Theme Name: Put Your Theme Name Here
Theme URI: Put Your Site Address Here
Description: Give it a short description
Version: 1.0
Author: Your Name Here

This information is read by WordPress and when you’ve uploaded your new theme (into its own directory under wp-content/themes/) and go to Admin – Design, you’ll see your theme as an option to be selected. If you want a thumbnail displaying too then create a screenshot of the theme and add it into your theme directory with the filename of screenshot.png or screenshot.jpg. This will also be automatically displayed by WordPress.

Next week I’ll write about how to edit your header, footer and sidebar files, ready to then set your theme live.

  • 1

Disclosure: In full disclosure, it is safe to assume that the site owner is benefiting financially or otherwise from everything you click on, read, or look at while on my website. This is not to say that is the case with all content, as all publications on the site are original and written to provide value and references to our audience.


  1. Py August 10, 2008
  2. Yuen August 11, 2008
  3. Sarah August 11, 2008
  4. A. Georgiev August 11, 2008
  5. Wooden Toys August 11, 2008
  6. Lloyd Lopez August 11, 2008
  7. Eva White August 11, 2008
  8. Aravind August 12, 2008
  9. elefint August 15, 2008
  10. Chuck August 18, 2008
  11. Ganesh August 20, 2008
  12. Armand August 21, 2008
  13. destiny jones October 3, 2008
  14. sam December 16, 2010