What’s an effective way of removing all the meta boxes for a specific post type in WordPress?
The only solution for removing metaboxes at all that I’ve found seems to be the remove_meta_box function, which requires an id of the metabox to be removed. I could remove all the default metaboxes like this, it would be a little fiddly but not impossible or even hard.
However, how would I go about consistently removing the meta boxes added plugins or theme functions elsewhere? Those are dynamic and unpredictable, maybe I can reliably get a summary of the meta boxes for a custom post types edit page and maybe work from there?
Thanks,
B
You can do this in one of two ways –
My personal preference would be method 2, although there will of course be some overhead compared to the more brutal method 1.
Using PHP
microtime
, the speeds are recorded as follows –Method 1 – quick and brutal –
Method 2 – slow and careful –
David has given you good options. I just used the following for your specific use-case: (Replace your_custom_post_type with the name of your CPT)
And then you can add your own meta-boxes as you like.