Remove metaboxes from custom post type

时间:2016-08-31 17:00:27

标签: wordpress custom-post-type meta-boxes

I want to remove all the metaboxes added by unrelated plugins to my custom post type, is this possible ?

I know I can use the function remove_meta_box(), but then I'll just remove the ones I currently have, but if any other plugin adds a metabox later on I'll have to manually remove it.

1 个答案:

答案 0 :(得分:0)

Here is sample code to do that. In my case I have found my metabox id,priority and position.

Plugin have added this metabox 'my-meta-box-id' to post type foo.

Here is the code to remove metabox

add_action('add_meta_boxes', 'remove_plugins_meta_boxes');
function remove_plugins_meta_boxes(){
    global $wp_meta_boxes;
    unset($wp_meta_boxes['foo']['normal']['high']['my-meta-box-id']);

}

By this way you can remove your meta box.