Most WordPress themes will come with several page templates by default.
Templates are used to display posts, archives,categories etc and there are many template files included in the theme folder.
The screen shoot below show the 2012 theme folder and highlights some of the template files:
Posts and Pages -Template File Associations
The template file used to display posts, archives, categories and most other WordPress page types is fixed, and cannot be changed in the administration panel.
However it is possible to change the template file used to display a particular page through the administration panel
For example the 2012 theme comes with 3 page templates by default, and you can change which template a page uses in the page administration panel, as shown in the screen shot below:
Creating New and Custom Template Files
The easiest way of creating a new template file is to copy an existing template file and edit it.
Because we are creating new page templates we start with the default page template file page.php and copy it.
Once you have copied it rename it and edit it.
What you must do is edit the template name as this is what will appear in the drop down box in the admin screen,
The screen shots below show the page.php file before and the copied page.php file after editing:
Copied page.php with edits for the template name at the top.
Note that the template file name and template name don’t have to be the same but should be to avoid confusion.
Now you need to customise the file to make it do what you need it to do. Normally you will place your code in between the div tags as shown in the screen shot below:
New Template File Locations
You could create the new template files in the same location as the existing ones, but they may get removed when you do a theme upgrade.
I prefer to use a child theme and create them there.
This also gives you the added flexibility that you can easily and safely create addition styles and functions to your new template.
If you are new to child themes see the How to create a child theme tutorial.
Assigning the Template to a Page
Open any page in the Control panel and you can select the new template from the list of templates in the drop down box.
This video takes you step by step through the entire process .Please like it if you found it useful.
Related Tutorials and resources:
- How WordPress Works
- Beginners Guide to WordPress Templates
- Understanding the Load Process
- Understanding the WordPress Loop