WordPress is_page() Function

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

Definition

In WordPress, is_page() returns true when the visitor is viewing a Page, such as About or Contact. Blog posts are not Pages, so they return false.

Call it with no argument to match every Page. Pass an ID, a title, or a slug to match one Page.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_page() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_page()True on any Page.
is_page( 'about' )True on the Page with the slug about.
is_page( array( 42, 'contact' ) )True on the Page with ID 42 or the slug contact.

For blog posts use is_single(). For both, use is_singular().

Full declaration
WordPress
is_page( int|string|int[]|string[] $page = '' ): bool

Parameters

ParameterDescription
$pageOptional. A Page ID, title, slug, or an array of them. Default is empty, which means any Page.

Return Value

Return ValueDescription
booltrue if the main query is for a Page, otherwise false.

WordPress Examples

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

Example 1 — Any Page

Add a class to every Page.

WordPress
<?php if ( is_page() ) {
  echo '<div class="page-wrap">';
} ?>

How It Works

  1. is_page() is true on every Page.
  2. Blog posts are not Pages.
  3. The wrapper is printed only on Pages.

Example 2 — One Page by slug

Show a phone number on the Contact page.

WordPress
<?php if ( is_page( 'contact' ) ) {
  echo '<p>Call us: 555-0100</p>';
} ?>

How It Works

  1. 'contact' is the Page slug.
  2. Only that Page returns true.
  3. Other Pages skip the line.

Example 3 — Several Pages at once

Use an array to match more than one Page.

WordPress
<?php if ( is_page( array( 'about', 'team', 'careers' ) ) ) {
  dynamic_sidebar( 'company-sidebar' );
} ?>

How It Works

  1. The array holds three Page slugs.
  2. The tag is true if the current Page is in the list.
  3. You can mix IDs, titles, and slugs.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
is_page() is for Pages. is_single() is for blog posts and custom post types. Use is_singular() for all.
It is true if the front page is a static Page. For a front page that lists posts, use is_front_page().
The slug is easy to read. The ID is the most stable if someone changes the slug.
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_page_template()

Check if the current Page uses a custom page template.

is_page_template() 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.

15 people found this page helpful