2
votes

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
For that you need to identify meta box position, priority and metabox id. - milan kyada
@milankyada that if I were to use "remove_meta_box()", right ? - VdeVentura
you can check my answer :) - milan kyada

1 Answers

0
votes

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.