Wordpress: How can I hook only on certain pages? Can I even do that?
So I created a action add_action( 'header', 'admin_bar', 8 );
, so that it loads in the header. However, I don't want it to load on certain pages, for example, post-new.php
. Ca开发者_如何学Pythonn I have a condition for hooks to load only certain pages?
I believe there is a $pagenow global. not sure if it's still there but you could var_dump($pagenow) on the pages you want to exclude to find the value then do something like this in your function...
function admin_bar() {
global $pagenow;
if ( 'post-new' != $pagenow || 'dashboard' != $pagenow ) {
//execute code
}
}
精彩评论