Did you know that you can create different page templates,and use it on your theme? Here’s a simple how-to about WordPress page templates, to get the most out of your theme!
Did you know that you can create different page templates,and use it on your theme? Here’s a simple how-to about WordPress page templates, to get the most out of your theme!
Page templates are very useful: They allow you to creates custom pages, for exemple creating an archive page which will list all your posts, or a page to display infos about the author.
A page template is defined by the following code, inserted on the firsts lines of the file:
<?php /* Template Name: Archives */ ?>
Here, we just created a page template, named "Archives".
To use it on your theme, write a page, and scroll down until you see a "Page Template" dropdown list, as described in the picture below:

Then you just have to choose which page template to use, and save the page.
63 Responses
I don´t understand, how can I do to create a page template? Exactly, where do I put this code? where is “on the firsts lines of the file”?
thank you
@Pablo: Create a blank file and add the code I shown in the article that way:
<?php
/*
Template Name: Archives
*/
?>
//Then start coding the page
Hope it is clearer now!
i allready have a page with the name “Archives”?
what i have to do?
and i cand fine the “Page Templates” in my admin Area?>
please help me
i found this is a quite nice post~
why not post more about create new template with respective posts display?
thanks for this post! it helps me a lot!
I’m sorry dude, but this is totally worthless. If you’re going to create a tutorial on this subject then, at least, make it complete. Unless you already know how to create a page template your instructions will mean nothing.
Even if people are able to create the template, it will simply be a blank page. What good is that? Put some more effort into this instead of just trying to get search results.
@Jeff: The purpose of this (short, I have to admit) tutorial is to learn to create a Page Template in WP. And it does it.
This tutorial purpose isn’t to display anything, simply to make people learn about page templates.
The problem I see with the tutorial is now I have this nice new page template sitting on my desktop and I don’t have a clue where to upload it to. From the tutorial, it should work sitting right where it’s at.
For people like me who have never used such before, it would be helpful to tell us where to upload the file to. Just a thought. . . .
That’s all?
page templates + ALL posts on a page = sitemap
already made in your blog
thx for tips
You forgot to mention what to do with the file! From the original article I thought we had to create a new page with the template code in it and WordPress would then automagically know it was a template. Buuut, after googling I found that:
“The directory to place the new page template in is blog/wp-content/themes/default. Where default is the currently active theme.”
Now all is well!
This is not a tutorial, iam a WP beginner and cant understand a word he has written.
@mahen : Maybe, or maybe you’re just too dumb to understand it.
Sorry but I have been working with Wordpress for over a year, but haven’t created a page template yet. When I try to follow your instructions, whichy I assume mean to add the PHP code into the cody of a new page, there is no drop down list that I can see that allows me to save the page as a template.
I am using Wordpress 2.8.6 and I know the layout has changed, but I can’t find a page template option anywhere.
I really would like to be able to create a page that contains an RSS Feed.
I tried using a widget (from feedwind) and although the headers and border appear, the content does not.
Presumably the feed code has to be in the template, because this generates the code for the page, not in the body of the page itself?
I just noticed (per the previous reader’s comment) that my 2.8.6 blogs don’t have page templates available any more. I assume this is a bug in the 2.8.6 release. I’m trying to find out more.
“Maybe, or maybe you’re just too dumb to understand it.”
What the hell kind of reply is that? This tutorial failed for a couple of reasons, and this is how you handle it – by calling your readers dumb? You just lost MAJOR points in my book, and I’ll be sure to drop by your posts over at Mashable.com and leave a reminder of how you handle things on your own blog.
@Jane : This post have 59 comments and trackbacks, this is not what I call a fail.
WpRecipes is a blog about WordPress Hacks, not “beginner tutorials”. Lots of sites already do that very well.
Then, if you think my blog sucks, I don’t have any problem with it.
Good stuff I was wondering how to use that blank file sitting around in my directory. For everyone who posted on here…it doesn’t take much to put a little effort into finding out what to do with this information. just change where it says Archives and change what you want to change in the page template,then find it in the drop down menu in the create a new page in wp-admin. Thanks again Jean
I tend to agree that this tutorial is a bit incomplete. The only thing that’s really missing is what to do with that code.
For those that don’t understand, you need to create a blank PHP file and add the code to it. For example, you could call it
page-archives.php. You then put that file into your currently active WordPress theme folder.Trackbacks: