How to Create a New Page Template in WordPress
WordPress allows you to create content based on page templates. Custom page templates enable the usage of alternate layouts throughout a site's pages, by defining new displays for headers, subheaders, menus, sidebars, and footers. This allows content authors to organize, manage, and present distinct information, while maintaining a consistent style throughout a site.
Instructions
-
-
1
Open a blank notepad document and type the following code at the top of the file, adding your custom template's new name after "Template Name":
<?php
/*
Template Name: [add the new template name here]
*/
?>
-
2
Save the file with a .php extension. The new filename can be almost anything except for the following WordPress reserved names, which are a part of the install assembly: "index," "comments," "front-page," "home," "single," "page," "category," "tag," "taxonomy," "author," "date," "archive," "search," "attachment," "image" and "404." An example of an appropriate filename with the .php extension would be "newlayout.php."
-
-
3
Copy the code from the existing file called "page.php" on the WordPress website. Do this by logging into the WordPress website as an administrator. Choose "Appearance," "Editor," then "page.php" to open the page in the editor window. Then select and copy everything in the editor window. Paste the code into your new notepad file below the code that defined the template name.
-
4
Add, remove, or reposition code within the file as needed to customize the new page template. For example, to remove a sidebar, delete "<?php get_sidebar(); ?>." To remove comments from the page, delete "<?php comments_template(); ?>." More information on such changes is available on the WordPress Codex website (see References for link).
-
5
Use FTP software such as FileZilla or CuteFTP to upload the new page template file to the theme directory under "/wp-content/themes/yourtheme/newlayout.php." The new page template will be available for selection when adding new pages or editing existing pages.
-
1
Tips & Warnings
Do not overwrite or alter the original "page.php" file. Such changes can destroy the site's existing page display or functionality.
References
Resources
- Photo Credit Jeffrey Coolidge/Photodisc/Getty Images
Comments
-
tahoethinker
Mar 02, 2011
Good one! I built a child theme and this will come in handy for sure.