Creating Custom Page Templates
Why use a custom page template?
Pages are hugely useful when using WordPress as a CMS, and when you’re making a website, it’s not uncommon for two pages to have entirely different layouts. Sometimes an if statement will do the trick; if not, you’ll need a custom page template.
A custom page template is a file located in your theme directory. With it, you can change the layout of a page or show different content to the standard page template (page.php). You can have an unlimited amount of page templates, and choosing the template you’d like to use for a particular page is as easy as selecting an existing template from a drop-down in the WordPress page editor.
How to create a custom page template
To create your custom page template, usually it’s easier to just copy an existing template and modify it. You can either create your new templage page file in your theme folder or create a new folder named for example ‘templates’ and create it inside it. All custom page templates must start with the following code. It tells WordPress that the file is a custom page template, and sets the name of the template.
<?php /* Template name: My Custom Page Template */ ?>
- Creating Custom Page Templates article.