The problem is that you’re trying to use is_page()
, a conditional function intended only to run adjacent to the query, too early. Try running your code inside a callback that 1) only fires on the front-end, 2) fires after the page has partially loaded. For instance, wp_head
.
function prefix_run_on_contact_us() {
if( is_page('contact-us')) {
echo "hello check";
//either in about us, or contact, or management page is in view
} else {
echo "Not working";
}
}
add_action( 'wp_head', 'prefix_run_on_contact_us' );