Custom Page Template in WordPress

In general most of the pages created from WordPress “Pages” section gets displayed using the “page.php” template file (aka theme file). However, there are cases when you may want to customize the look and feel of any specific page that stands out from the regular template. In such cases, using custom template is the best option that you can have.

Custom page template is particularly useful if you want to add custom functionality on any specific page. Case in point, we can think about the “contact” page for a site where you may want to have a contact form that visitors can use to get in touch with you or email you. In order to create a custom page template, you can simply copy and past the existing “page.php” page and then modify it to get your job done. Open up your “page.php” page with your HTML editor and add the following lines at the very beginning of your page.

<?php 
/* Template Name: Contact */ 
?>

Next thing you need to do is to save it with a different file name. Now, even though there are various methods that can be used here, I would suggest you follow this (page-{page-name}.php) pattern. In other words, you can save your custom template for contact page as “page-contant.php”.

Reference: Page Templates

Today In History

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.