You can use remove_meta_box() to accomplish that.
To use remove_meta_box()
you will need 3 pieces of information:
- the
id
of the meta box you want to remove - the
screen
(or screens) you want it removed from - the
context
it was added in (e.g., ‘side’, ‘normal’, etc)
To get these 3 pieces of info, search thru the source for the theme for add_meta_box()
call(s) that are used to add the meta box.
And in case it’s not obvious, make sure you call remove_meta_box()
in an action that is fired after whatever action the meta box was added in.
For example, if the theme looks like:
add_action ('after_theme_setup', 'add_theme_meta_boxes') ;
function
add_theme_meta_boxes ()
{
add_meta_box ('ad-to-upgrade-to-pro', 'Upgrade to Pro', 'render_upgrade_ad', 'post', 'normal', 'high') ;
return ;
}
The your plugin should contain the following:
// make sure you hook to an action that is fired *after* the meta box was added
add_action ('init', 'remove_theme_ad_meta_box') ;
function
remove_theme_ad_meta_box ()
{
remove_meta_box ('ad-to-upgrade-to-pro', 'post', 'normal') ;
return ;
}
Edit
To answer the question asked in comment: it is not possible to absolutely guarantee that no other theme/plugin adds meta boxes.
Besides, with an open system like WP, it is not a good idea to do what you are trying to do (IMHO). There are a whole host of “general purpose” plugins out in the wild that have legitimate reasons for adding meta boxes to your CPT’s post{,-new}.php
screens.
For example, the WordPress SEO plugin adds a meta box to any post type that is “viewable” that allows adding SEO-related metadata to the public page for posts (note: mention of WordPress SEO is not meant as an endorsement, it’s just the 1st one that came to mind).