is_page

Home » Functions » is_page

The is_page function is a conditional tag in WordPress that checks whether the current page being viewed is a page or not. Pages in WordPress are a type of content that is typically used for static content, such as an About page or a Contact page.

The function returns a boolean value, true if the current page is a page, and false if it is not. This function is commonly used in WordPress theme development to apply specific styles and functionality to pages as opposed to posts or other types of content.

Example Usage:

if ( is_page( 'about' ) ) {
    // code to execute if the current page is the About page
} else {
    // code to execute if the current page is not the About page
}

In this example, the is_page function is used to check whether the current page being viewed is the About page. If it is, the code inside the if statement will be executed, otherwise, the code inside the else statement will be executed. This can be useful for applying specific styles or functionality to certain pages on a WordPress site.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.