Codex tools: Log in
This Conditional Tag checks if Pages are being displayed. This is a boolean function, meaning it returns either TRUE or FALSE. This tag must be used BEFORE The Loop and does not work inside The Loop (see Notes below).
<?php is_page($page); ?>
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.
Be very careful if there's a possibility of passing an empty value as a parameter to check for a specific page, since the following lines will return true:
is_page( '' ) is_page( 0 ) is_page( '0' ) is_page( null ) is_page( false ) is_page( array() )
Due to certain global variables being overwritten during The Loop
is_page() will not work. In order to use it after The Loop you must call wp_reset_query() after The Loop.
is_page() is located in