How to create a custom WordPress page template

By default all pages in WordPress use the 'page.php' template file to format the structure. If you want to setup a different template structure that can be re-used for multiple pages, follow the steps below.

  • Copy the 'page.php' default page template from your parent theme folder into your child theme folder (note you could just create an empty file, but you might find this easier as a starting point).
  • Rename the copied file to something appropriate for your template (e.g. 'my-custom-page.php'). Do not prefix the name with 'page-' as this would be registered as 'specialised', which is used for overriding individual pages. 
  • Place the following code at the top of the new file:

    <?php
    /*
    Template Name: Custom Page
    */

Now you can start editing this file to your requirements.

To use the new template, login to the admin panel and go to the page you want to assign the template to. You'll notice that your new template has now been registered in the 'Page Attributes' section on the right hand side under the 'Template' drop down. 

You can use the template on as many different pages as you want.

Read more about page templates in the WordPress Codex.

Sign Up
comments powered by Disqus
Sign Up

Popular Tags

350x250

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.