Possible Duplicate:
Change The Title Of a Meta Box
是否可以更改特定自定义帖子类型添加或编辑页面上元框的标题?
例如,如果我正在查看自定义帖子类型的帖子类型添加或编辑页面:my_custom_post_type_name
, 我是否可以将元框重新标记为“发布”为更像“我的CPT操作”?
Possible Duplicate:
Change The Title Of a Meta Box
是否可以更改特定自定义帖子类型添加或编辑页面上元框的标题?
例如,如果我正在查看自定义帖子类型的帖子类型添加或编辑页面:my_custom_post_type_name
, 我是否可以将元框重新标记为“发布”为更像“我的CPT操作”?
是-您需要稍微修改版本的this answer.
add_action( \'add_meta_boxes_post\', \'wpse39446_add_meta_boxes\' );
function wpse39446_add_meta_boxes( $post ) {
if( \'mycpt\' == get_post_type($post) ){
remove_meta_box( \'authordiv\', \'mycpt\', \'core\' );
add_meta_box( \'authordiv\', __(\'Team Member\',\'wpse39446_domain\'), \'post_author_meta_box\', \'mycpt\', \'advanced\', \'high\' );
}
}
Note: 如果要对非核心元盒执行此操作,则需要通过指定更高的优先级来确保在添加元盒后调用回调。我已经想出了一个效果很好的解决方案,没有实际“删除”核心WordPress元框。
public function rename_metaboxes(){
global $wp_meta_boxes;
/* Specified Custom Post Type. */
$custom_post_type = \'mbe_c2c_groups\';
/* Only perform these actions on Adding or Editing pages for the specified Custom Post Type. */
if(array_key_exists($custom_post_type, $wp_meta_boxes)){
/* Make a backup copy of the original Meta Boxes. */
$meta_box[\'publish\'] = $wp_meta_boxes[$custom_post_type][\'side\'][\'core\'][\'submitdiv\'];
$meta_box[\'featured_image\'] = $wp_meta_boxes[$custom_post_type][\'side\'][\'low\'][\'postimagediv\'];
/* Remove the original Meta Boxes from the Custom Post Type. */
unset($wp_meta_boxes[$custom_post_type][\'side\'][\'core\'][\'submitdiv\']);
unset($wp_meta_boxes[$custom_post_type][\'side\'][\'low\'][\'postimagediv\']);
/* Re-label the "Publish" Meta Box. */
$meta_box[\'publish\'][\'title\'] = \'Group Actions\';
/* Re-label the "Featured Image" Meta Box. */
$meta_box[\'featured_image\'][\'title\'] = \'Group Image\';
/* Re-add our Meta Boxes to the Custom Post Type. */
$wp_meta_boxes[$custom_post_type][\'side\'][\'high\'][\'submitdiv\'] = $meta_box[\'publish\'];
$wp_meta_boxes[$custom_post_type][\'side\'][\'high\'][\'postimagediv\'] = $meta_box[\'featured_image\'];
}
}
add_action(\'in_admin_header\', array($this, \'rename_metaboxes\'), 9999);
Yoasts SEO插件在后期编辑屏幕中添加了一个元框。我正在尝试为非编辑或更高级别的用户删除此项。我试着把remove_meta_box 在admin\\u init上调用,尝试删除$wpseo\\u metabox上的操作,但没有效果。如何在不需要用户干预的情况下删除此元数据库(用户永远不会知道该元数据库存在,因此单击屏幕选项不是一个选项)