Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a away to create a custom post type in wordpress that will only include the default metaboxes and not any other metabox that was added by other plugins.

The idea is to use the custom post to develop a plugin, this plugin will need to have all the functions custom post type but with all the metaboxes that plugin add like all-in-seo.

I want to create a clean interface for the user and those extra metaboxes are in the way :-)

share|improve this question
    
Meta boxes are added to the global $wp_meta_boxes array. You can inspect the array, empty it entirely, and pass in your desired meta boxes for registration on the desired page(s) you specify in your condition. Look closely at add_meta_box and remove_meta_box in wp-admin/includes/template.php for more help. –  userabuser Oct 15 '13 at 8:52
add comment

3 Answers

Off the top of my head, without actually testing it, this should work. You want to test for is_admin so we don't go running the code on the front end, then also test for the post type being equal to its slug. Edited this because I made a silly mistake before.

Reference this page of the Codex: http://codex.wordpress.org/Function_Reference/remove_meta_box

if( is_admin() ) {
    remove_meta_box('linktargetdiv', '$posttype', 'normal');
    remove_meta_box('linkxfndiv', '$posttype', 'normal');
    remove_meta_box('linkadvanceddiv', '$posttype', 'normal');
    remove_meta_box('postexcerpt', '$posttype', 'normal');
    remove_meta_box('trackbacksdiv', '$posttype', 'normal');
    remove_meta_box('postcustom', '$posttype', 'normal');
    remove_meta_box('commentstatusdiv', '$posttype', 'normal');
    remove_meta_box('commentsdiv', '$posttype', 'normal');
    remove_meta_box('revisionsdiv', '$posttype', 'normal');
    remove_meta_box('authordiv', '$posttype', 'normal');
    remove_meta_box('sqpt-meta-tags', '$posttype', 'normal');
}
share|improve this answer
    
First of all thanks, but ... This will only work on regular metaboxes and not on ones that was created by other plugins like all-in-seo and similar. –  Bob Tolbert Oct 15 '13 at 6:46
    
Right, sorry I got that question backwards in my head. Whoops. You should be able to conditionally remove the function associated with the meta box but it'll often require an additional priority of 99 and knowing exactly what all the meta boxes are, how they are named, and where they are hooked. It's barely practical on a single site and would be a nightmare on multi. –  Imperative Ideas Oct 15 '13 at 7:20
    
Yes that's what I have figure it out before but i wanted to be absolutely sure because the other solution is to develop the entire interface from scratch. –  Bob Tolbert Oct 15 '13 at 14:53
    
If we're talking about non-administrative users, check out something like the CRED plugin from WP-Types. It's literally designed for rapid prototyping a front-end page editor: wp-types.com/home/cred –  Imperative Ideas Oct 16 '13 at 8:01
add comment

First of all you shouldn't do it. If a user have installed other plugins, it is because he/she want ot use it, even if your plugin provide all functionalities of that plugins, who say that for the users your plugin is better than others?

And if that users already have tons of settings with other plugins and see them disappear installing your plugin? I bet that users immediately unistall your plugin (and if there is possibility very low votes will come in that case).

Also consider that another plugin can use the same technique to remove your metaboxes. An the another plugin will remove the metaboxes of that plugin, and so on...

What it will be, the war of metaboxes?

My suggestion is to add your metaboxes and let users decide what metaboxes to leave and what to remove (unistalling plugin or unchecking the metabox from the "screen help" tab).

Finally, note that you can't remove metaboxes of a plugin if you don't know the id of those metaboxes. So to do what you want you should install all your "competitors" plugins, look at the id of their metaboxes and remove them using remove_meta_box.

And if a plugin get updated and change the id of its metaboxes?

Believe me, it's and hard, dirty, no-benefit work.

share|improve this answer
    
"The War of MetaBoxes" it's should be a name of the movie. It's not about functionality some metaboxes are just not relevant to the content that is going to be in the custom post type. For example if post type is managing redirects like simple urls plugin a metabox of a plugin that deals with membership website is just not relevant to that custom post type. Thank you for answer –  Bob Tolbert Oct 15 '13 at 14:48
add comment

You can find the best answer here: http://codex.wordpress.org/Function_Reference/remove_meta_box

Certain meta boxes can be removed by adding something like the code below to the functions.php file in your WordPress theme:

// hide certain meta boxes on the 'YOUR_CUSTOM_POST_TYPE' custom post type
add_filter('add_meta_boxes', 'hide_meta_boxes_YOUR_CUSTOM_POST_TYPE');
function hide_meta_boxes_concerts() {
    remove_meta_box('postexcerpt', 'YOUR_CUSTOM_POST_TYPE', 'normal');
    remove_meta_box('trackbacksdiv', 'YOUR_CUSTOM_POST_TYPE', 'normal');
    remove_meta_box('postcustom', 'YOUR_CUSTOM_POST_TYPE', 'normal');
    remove_meta_box('slugdiv', 'YOUR_CUSTOM_POST_TYPE', 'normal');
    remove_meta_box('commentstatusdiv', 'YOUR_CUSTOM_POST_TYPE', 'normal');
    remove_meta_box('commentsdiv', 'YOUR_CUSTOM_POST_TYPE', 'normal');
    remove_meta_box('revisionsdiv', 'YOUR_CUSTOM_POST_TYPE', 'normal');
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.