How to use is_page conditional in wordpress

How to use is_page conditional in wordpress

Many people some another content or code need to add in specific pages. WordPress tutorial for, How to use is_page conditional in wordpress.

use is_page conditional in wordpress

How to use is_page conditional in wordpress
How to use is_page conditional in wordpress

In that senorio use should use the is_page condition in page.php file. This file you will find in active wordpress theme folder.

You can use is_page condition in multiple way. Following are the some 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

Note: You can use above condition in only page.php file.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.