How to add custom page template in wordpress?

What is a custom page template?

In wordpress a custom page template is used to create different layouts for different pages. If we are using a page.php then we need to apply code in it for each page using its id ( if they don’t have common layout ).

Custom page template helps when you have different pages such as portfolio, blog etc or different layouts for blog page. For example blog page with right sidebar or left sidebar or double sidebar etc etc. If you want to show different layouts for posts go to custom post types.



How to add custom page template?

Above is the code that you need to place in header of your pageTemplate.php file or whatever name you want to use for file. Now goto admin panel and click edit page for any page or add new page. You will find your page template name in page attributes meta box under tempate dropdown as shown in image above.


Custom page template not working or doesn’t show up in page attributes meta box?

Please check if you have done following two things:

  • Place code for custom page template in page.php with name default
  • Don’t place space between “Template name” and”:” i.e. it should not be written as “Template name :”. So correct format is”Template name:”.



Leave a Reply

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

%d bloggers like this: