Creating a New Page Template for a WordPress Theme

July 8, 2010 | By

Page templates in a WordPress theme define how the page using it is displayed. Nowadays most themes provide more than one page template. As an example the Twenty Ten theme that comes with WordPress 3.0 has Page Template and One Column, no Sidebar Page Template. They are listed in the Page Attributes box in the Template drop-down list when you create or edit a page.

Page Attributes

You could create a new page template easily if you would like to make a few pages look different from the rest of your website. To create one follow the steps below:

  1. Create a file with a .php extension and a descriptive name, so you could find it easily in the WordPress theme editor. You could create the file locally on your computer and upload it using an FTP client when you finish the tutorial or just create it in the theme’s folder using your web host’s control panel.
  2. At the beginning of the file and before anything else enter the following comment, changing Template1 to the name you would like displayed in the Template drop-down list when editing a page. WordPress gets the template’s name from here so format the name exactly the way you want it to appear.

  3. In WordPress click on Editor under the Appearance menu to open the theme editor. If the theme you want to add the page template to is not the current one you could select it using the drop-down list on the top right corner. And click on the page template you want to duplicate from the list of files on the right.
  4. Copy the contents of the file starting after the end of the first comment and paste it at the end of the file you created.
  5. Now just upload the file to the theme’s folder if you haven’t done so already.

Now that the page template is created you can use it with pages and you could modify it in the theme editor to differentiate the pages using it from the rest of the website.

Filed in: WordPress | Tags:

Comments (5)

  1. Exactly what I needed to get my new template operational! I had copied and modified the default theme but forgot the change it’s name.

    Thanks a million for posting!

  2. I never imagined it would be THAT simple! Great Post!

  3. Chad

    Thank you! This is the solution I was looking for.

  4. mejiwara

    The page template I created is not showing on the page attributes panel. What could the problem be? Help.

  5. @mejiwara, make sure the PHP comment in step 2 is at the top of the page and is formatted like the code sample. WordPress reads the template name from it.