In this article, We are going to see How To Create a Page Template In WordPress.
There are three types to create page templates in WordPress.
- Custom Page Templates for Global Use
- Custom Page Template for One Specific Page
- Page Templates for Specific Post Types
1. Custom Page Templates For Global Use
In which template can be used globally on any page or multiple pages.
Step-1: Create a new PHP file and add the below code in this file.
<?php /* Template Name: PageTemplate */ ?> <h1><?php wp_title(''); ?></h1> <p>Creating a Custom Page Template for Global Use</p>
The following information is required:
- Template Name – This needs to be unique to your template.
Please check the below video:
2. Custom Page Template For One Specific Page
In which template is used for only a specific page.
Step-1: Create a page.php file and rename it width your page’s slug or ID:
- page-{slug}.php
- page-{ID}.php
For example, Your example page has a slug of ‘example’ and an ID of 3. If your active theme’s folder has a file named page-example.php or page-3.php, then WordPress will automatically find and use that file to render the example page.
3. Page Templates For Specific Post Types
In which template is used for only a specific page type.
Step-1: Create a new PHP file and add the below code in this file.
<?php /* Template Name: SpecificPageTemplate Template Post Type: movies */ ?> <h1><?php wp_title(''); ?></h1> <p>Creating page templates for specific post types</p>
The following information is required:
- Template Name – This needs to be unique to your template.
- Template Post – need to add specific post type.
Please check the below video:
Thank You, hope you guys found something useful.