March 29, 2010

How to Create and Define your own WordPress Template

When I first started out using WordPress, I had only one page template. Inside my index.php file under my theme folder, I would run case-statements that would check the page id, and then I would insert my desired html inside each case. Needless to say, this is NOT how you should be developing on WordPress.

After watching a screen cast by Chris Coyier, I discovered that you could create page templates for your different page structures. Let’s say you have a splash home page, a blog, and a photo archive. All three of these pages would probably need to have their own design structure. To accomplish this, you simply copy one of your current page layouts, say…index.php. You create a new file and name it something related to it’s theme, like splash-page.php. You then paste your code and structure it the way you need your spash page to be. Make sure you add this snippet of code to your header.

<?php
/*
 * Template Name: Splash Page
 *
 */
?>

This is needed so your new template will show up from the drop down menu for your template selection. Click on the picture below to see where to change your pages template.

Here is the link to the technical specs about creating your own WordPress theme.

Leave a comment