How To Create a Custom Page Template in WordPress

wordpress-custom-page-template

What is default template file in WordPress

page.php of your theme is used to show default template page.

Why We Need Custom Page Template

You may need to display contents in different layouts and styles. Like I want a page template that has no sidebar. And for this we need different custom page template.

How To Create a Custom Page Template

  1. Let’s create a new page template named Tutorial.
  2. Create a copy of page.php file of your theme and rename it as tutorial-template.php
  3. Open tutorial-template.php in any text editor. Add following codes at the top of page.
  4. 1
    2
    3
    4
    5
    <?php
    /*
     Template Name: Tutorial
     */

    ?>
  5. Edit code of tutorial-template.php as per your requirements.

Done!!

Create a new page and now you can see this new template Tutorial as an template option.

Similarly you can create many custom page template files.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *