当你尝试使用这个函数时,你使用了什么钩子?你想过吗?我一直都是这样:)在我看来,你已经有了最早的钩子,我测试了几个,但都太早了。
解决方案1:
add_action(\'parse_query\', function () {
if( is_page(\'contact-us\')) {
echo "hello check";
//either in about us, or contact, or management page is in view
} else {
echo "Not working";
}});
解决方案2:
add_action(\'parse_query\', function () {
if( \'contact-us\' == get_query_var(\'pagename\') ) {
echo "hello check";
//either in about us, or contact, or management page is in view
} else {
echo "Not working";
}
});