在 WordPress 的早期版本中,从某些帖子类型中删除元框相对容易。在 Wp 5.0.2 中,它看起来并不那么简单。我想删除右侧边栏中的“讨论”元框,但是下面的内容不起作用?
function remove_post_custom_fields() {
remove_meta_box( 'commentstatusdiv', 'post', 'side' );
}
add_action( 'admin_menu' , 'remove_post_custom_fields' );
最佳答案
您必须使用名为“删除元框”的功能。
<?php
add_action( 'default_hidden_meta_boxes', 'acme_remove_meta_boxes', 10, 2 );
function acme_remove_meta_boxes( $hidden, $screen ) {
if ( 'acme_post_type' == $screen->id ) {
$hidden = array(
'acme_post_type_categorydiv',
'authordiv',
'postexcerpt',
'slugdiv'
);
}
return $hidden;
}
?>
关于php - WordPress 5.0 删除讨论元框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53882939/