How to create a page template in WordPress

If you want a different page layout rather than all your pages, you need a custom page template. Custom page template gives you the ability to create and have special pages for your WordPress site. So, page template is usually different from rest of the designs of your site.

We can easily do that just by adding a single line inside the header comments area. To do that, copy your index.php page and rename it. I have given this template name is “Page with sidebar” . You can give any name here. You can add diffrent HTML layout in this page to test that this page is different from other page and it is holding the page template.  then in the header add the following line:

 

<?php
/**
* Template Name: Page with Sidebar
*
*/

get_header(); ?>

 

The one line is enough to create  page template that you can use while creating pages. When you create it and save it inside your theme files. You will see this page name in the Page attributes dropdown, there you can select and use it for a specific page.

 

create a page template
Custom page template in Template dropdown

 

Look at the above picture that a new page template has been added in the Template dropdown area. here you can select and use for a page. Let me know if you have any issue creating a page template in a WordPress theme.

1 thought on “How to create a page template in WordPress”

  1. Pingback: How to add or create a page in WordPress - FEKBD.COM

Leave a Comment

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

Scroll to Top