WordPress is_page_template() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Conditional tag

Definition

In WordPress, is_page_template() returns true when the current Page uses a custom page template, for example template-about.php.

Call it with no argument to check if the Page uses any custom template. Pass a file name to check for one template.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_page_template() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_page_template()True if the Page uses any custom page template.
is_page_template( 'template-about.php' )True if the Page uses that template file.
is_page_template( 'templates/landing.php' )Use the path when the file is in a sub-folder.

A custom page template starts with a comment like Template Name: About Page.

Full declaration
WordPress
is_page_template( string|string[] $template = '' ): bool

Parameters

ParameterDescription
$templateOptional. The template file name (with the folder if there is one), or an array of them. Default is empty, which means any custom page template.

Return Value

Return ValueDescription
booltrue if the Page uses the template, otherwise false.

WordPress Examples

Three short theme examples. Each one shows what prints on the true path and the false path.

Example 1 — One template

Add a class for pages that use the About template.

WordPress
<?php if ( is_page_template( 'template-about.php' ) ) {
  echo '<div class="about-wrap">';
} ?>

How It Works

  1. The argument is the template file name.
  2. is_page_template() is true only for Pages that use it.
  3. Other Pages skip the wrapper.

Example 2 — Any custom template

Check if a Page uses a custom template at all.

WordPress
<?php if ( is_page_template() ) {
  echo 'This Page uses a custom template.';
} ?>

How It Works

  1. With no argument, the tag matches any custom template.
  2. Default pages return false.
  3. It is useful for styling decisions.

Example 3 — Template in a sub-folder

Include the folder in the file name.

WordPress
<?php if ( is_page_template( 'templates/landing.php' ) ) {
  // no sidebar on landing pages
} else {
  get_sidebar();
} ?>

How It Works

  1. The folder is part of the template name.
  2. The if branch is empty on purpose, so no sidebar is printed.
  3. The else branch calls get_sidebar().

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
The Page may use the default template, or the name may not match. Check the exact file name and folder.
Yes, if the template file is inside a sub-folder of your theme.
No. is_page() checks the page type. is_page_template() checks which template file the Page uses.
Conditional tags need the main query. Call them in template files or on hooks such as wp or template_redirect, not directly at the top of functions.php.

Next: is_plugin_active()

Check if a plugin is active on the current site.

is_plugin_active() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful