How to: Create and use WordPress page templates

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:

Create and use WordPress page templates

Then you just have to choose which page template to use, and save the page.

43 Responses

Nov 21 2008 00:11

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

Nov 21 2008 00:35

@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!

Nov 21 2008 17:56

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

Apr 15 2009 18:24

i found this is a quite nice post~

Jun 11 2009 09:58

why not post more about create new template with respective posts display?

Jun 24 2009 13:27

thanks for this post! it helps me a lot!

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required
Blog And Make Cash