The appearance of all the pages and posts that are created on a WordPress website is handled by a template file named page.php.
Basic knowledge of HTML CSS and PHP is required to create a custom template in WordPress.
Let us begin to add a custom page template to an existing theme.
Step 1) Navigate to your theme’s folder as shown below:
Step 2) Open a text editor and add the following code.
<?php /* Template Name: TWSTemplate*/ ?>
Save as TWSTemplate.php
Step 3) Go to WordPress Admin Panel > Pages > Add New. You can see the new custom page template listed on the right side.
Step 4) Create a new page and set its template to TWSTemplate. Once done, Publish it.
You will see a blank page without any design as shown below. This shows that the custom page template in WordPress is successfully implemented
The default appearance of the pages is generated by page.php file located in /wp-contents/themes/YOUR THEME/ folder. Open page.php and copy its code and customize.
Refresh the page to check your custom template.
You are good to go!
Why I have created a custom page template when I could have easily edited the page.php file?
If page.php file is edited, all the pages across the website would show the changes.
In order to apply customized appearance on specific pages, custom page template in WordPress comes is useful.