function hide_editor_page(){
global $_wp_post_type_features;
$post_type= "page";
$feature = "editor";
if(isset($_wp_post_type_features[$post_type][$feature])):
unset($_wp_post_type_features[$post_type][$feature]);
endif;
}
function test1(){
global $template;
global $_wp_post_type_features;
$post_type= "page";
$feature = "editor";
if(basename($template) == "contact.php"):
remove_action("init","hide_editor_page",10);
endif;
}
add_action('init','test1',5);
有人能建议hide_editor_page运行良好,但当尝试使用basename($template(条件使用test1删除它时,它不起作用。如果没有basename($template(条件,remove_action将起作用。
解决方案1
如果您的contact.php页面没有发出任何HTTP GET请求,请尝试使用$_SERVER['REQUEST_URI']
而不是basename($template)
if($_SERVER['REQUEST_URI'] == "contact.php"):
remove_action("init","hide_editor_page",10);
endif;
解决方案2
如果example.com/whatever/
是您的URL,它将在$current_slug
中返回whatever
global $wp;
$current_slug = add_query_arg( array(), $wp->request );
if($current_slug == "contact.php"):
remove_action("init","hide_editor_page",10);
endif;
让我知道它是否有效!