Creating a Page Template

Creating your own page template is straightforward, as the simple example in this section shows. The process gets more complicated when you want the template to do something more useful. Chapter 12, which deals with themes, covers a few of the WordPress tags you can use to turn this template from a proof of concept to something that may be useful for your blog.

Page templates are located in the root of your theme's folder. For this example, you add a template to the default WordPress theme.

To create an example page template, follow these steps:

1. Open your text editor of choice.

I like TextMate in Mac OS X, but you can use any free text editor that's available for your platform, such as Notepad or TextEdit.

2. Type the following code:

Template Name: Example Template */

This code tells WordPress that the file is a page template. The Template Name parameter sets the name of the template, which will be displayed in the Page Template drop-down menu (refer to "Page Template" earlier in this chapter). In this example, you name the template Example Template because I have no imagination.

The rest of the template is code that does something.

3. Enter the rest of the example template, which calls the header and footer of the current theme and displays a message:

4. Save the template as a PHP file.

Make sure that the file extension is .php; otherwise, the file won't work.

5. Upload the template to the default theme folder, which is located here in your WordPress installation:


wordpress is the directory containing your WordPress installation.


The template should appear in the Page Template drop-down menu now (Figure 8.7). Pretty cool, huh?

Figure 8.7 The example template displayed with the rest of the page templates.

Page Template

Default Template j -

Default Template


Example Template


If you visited a page that actually used this template, though, the template wouldn't serve any useful purpose; it wouldn't even display the Hello, world! message in an attractive way. See Chapter 12 for details on transforming this template into a helpful page.

Was this article helpful?

0 0
Blog Your Way To The Top

Blog Your Way To The Top

How Any Business Builder Can Turn A Simple Blog Into A Lead Generating, Organization Cash Cow For Any Home Based Business! Everyone knows that in order to succeed in your home based business or your MLM / Network Marketing business, you need to adopt the latest strategies when it comes to making massive money.

Get My Free Ebook

Post a comment