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.

/* 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


Commenting is disabled.