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.

How can I remove the Featured Image meta box? I've tried using the remove_meta_box function and specifying the boxes ID but it doesn't seem to work like it does for the other native meta boxes.

Here is the specific code I tried:

add_action( 'admin_menu', 'remove_thumbnail_box' );

function remove_thumbnail_box() {
    remove_meta_box( 'postimagediv', 'post', 'side' );
}
share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

I haven't had time to test this but this looks like it should work for you.

add_action('do_meta_boxes', 'remove_thumbnail_box');

function remove_thumbnail_box() {
    remove_meta_box( 'postimagediv','post','side' );
}

Check this for more info.

Edit: The main change here is that you need to attach the function to do_meta_boxes instead of admin_menu

share|improve this answer
    
NOTE: You can also check the post type by looking at the variable passed to your callback (if you wanted to make this changes to set types), of course remembering to add the incoming var into the function, ie. function remove_thumbnail_box( $post_type ) –  t31os Dec 6 '10 at 22:57
add comment

The post thumbnail is added to a post type as something this post type supports. If you want to remove post thumbnail functionality from a post type, you can call remove_post_type_support(). Regular posts are also defined as custom post types, so it should work for them too.

add_action( 'init', 'wpse4936_init', 100 /* Something high, to make sure all post types are registered */ );
function wpse4936_init()
{
    remove_post_type_support( 'post', 'post-thumbnail' );
    // Or remove it for all registerd types
    foreach ( get_post_types() as $post_type ) {
        remove_post_type_support( $post_type, 'post-thumbnail' );
    }
}
share|improve this answer
    
Thanks Jan. Can you explain what add_action( 'init', 'wpse4936_init', 100 ); function wpse4936_init() { is all about? I've never seen anything like this. –  matt Dec 6 '10 at 18:37
    
Also, I'm not actually trying to remove support of it, I'm must trying to remove the meta box (so I can add it in later into an existing custom meta box. I probably should have specified but I was trying to keep it simple. –  matt Dec 6 '10 at 18:39
    
@matt: If you just want to remove the metaboxes then this is not what you want. The third parameter of add_action() defines the priority: the default is 10, so if you specify 100 it will run after all those of lower priority. You do this to make sure all custom post types are created (they usually are in the init hook), also those from other plugins. –  Jan Fabry Dec 6 '10 at 22:13
    
@Jan, I was actually already aware of what the init and 100 were it's the wpse4936_init that I've never seen before. What is that? –  matt Dec 6 '10 at 22:44
    
@matt: It's just the name of my function that I use as a callback! You have to use a unique function name, so I prefix all my function names in example code here with "WordPress Stack Exchange" and the question number, in case anyone just copies and pastes it in their code. –  Jan Fabry Dec 6 '10 at 22:49
show 1 more 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.