0

Currently I have this code in my function file:

    // REMOVE POST META BOXES
function my_remove_meta_boxes() {
    if ( ! current_user_can('administrator') ) {
        remove_meta_box( 'tagsdiv-post_tag', 'post', 'advanced' );
        remove_meta_box( 'postimagediv', 'post', 'advanced' );
    }
}
add_action( 'admin_menu', 'my_remove_meta_boxes' );

And the tags meta box has been disabled, but not the featured image box. I've looked elsewhere in my functions to see if anything is making it appear again but I cannot seem to find anything.

Is there perhaps something I am missing elsewhere?

1

1 Answer 1

1

The context or the 3rd parameter of remove_meta_box() function for tags meta box and featured image meta box is side. And perfect hook to remove meta box is add_meta_boxes. So try the following code, hope it'll work as expected.

function my_remove_meta_boxes() {
    if ( ! current_user_can( 'administrator' ) ) {
        remove_meta_box( 'tagsdiv-post_tag', 'post', 'side' );
        remove_meta_box( 'postimagediv', 'post', 'side' );
    }
}
add_action( 'add_meta_boxes', 'my_remove_meta_boxes' );
2
  • Thank you so much!! That did the trick! I think it was the hook as I had tried 'normal' and 'side' and nothing was working. Yay!!
    – Shuler
    Commented Feb 23, 2018 at 18:52
  • 1
    Glad to hear that it worked :)
    – obiPlabon
    Commented Feb 23, 2018 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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