WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:roscius/function template

Contents

Description

This Conditional Tag checks if Pages are being displayed. This is a boolean function, meaning it returns either TRUE or FALSE.

Usage

<?php is_page($page); ?>

Parameters

$page
(integer) (optional) Page ID, Page Title or Page Slug
Default: None

Return Values

(boolean) 
True on success, false on failure.

Examples

is_page();
// When any single Page is being displayed.

is_page(42);
// When Page 42 (ID) is being displayed.

is_page('Contact');
// When the Page with a post_title of "Contact" is being displayed.

is_page('about-me');
// When the Page with a post_name (slug) of "about-me" is being displayed.

is_page(array(42,'about-me','Contact'));
// Returns true when the Pages displayed is either post ID 42, or post_name "about-me", or post_title "Contact".  Note: the array ability was added at Version 2.5.

Notes

Be very careful if there's a possibility of passing an empty array as a parameter since

 is_page( array() ) 

will return as true.

Change Log

Since: 1.5.0

Source File

is_page() is located in wp-includes/query.php.

Related

See also index of Function Reference and index of Template Tags.