WordPress

How To Create Page Template In WordPress

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.

  1. Custom Page Templates for Global Use
  2. Custom Page Template for One Specific Page
  3. 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:

  1. 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:

  1. Template Name – This needs to be unique to your template.
  2. Template Post – need to add specific post type.

Please check the below video:

Thank You, hope you guys found something useful.

Mitali Kukadiya

I am a Junior WordPress Developer at Vision Infotech. I have good skills in WordPress, PHP, HTML, CSS, and jQuery.

Share
Published by
Mitali Kukadiya

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago