remove_meta_box

Home » Functions » remove_meta_box

Function Name: remove_meta_box

Have you ever wanted to remove a specific meta box from a WordPress post edit screen? Well, the remove_meta_box() function is here to help you with that.

This function is used to remove a meta box from a post edit screen in WordPress. Meta boxes are the boxes that hold additional information about a post, like categories, tags, featured image, etc. Sometimes, you may want to remove a meta box that is not relevant or necessary for your specific needs.

The remove_meta_box() function takes three parameters:

  1. $id (string) – The ID of the meta box to be removed.
  2. $screen (string) – The type of screen to remove the meta box from (post, page, custom post type).
  3. $context (string) – The context of the meta box (normal, advanced, side).

Here’s an example code that removes the ‘tagsdiv-post_tag’ meta box from the post edit screen:

function remove_tags_meta_box() {
    remove_meta_box('tagsdiv-post_tag', 'post', 'side');
}
add_action('admin_menu', 'remove_tags_meta_box');

In this example code, we use the remove_meta_box() function inside a custom function called ‘remove_tags_meta_box()’. We then use the add_action() function to attach this custom function to the admin_menu hook, which is called when the WordPress admin menu is being generated. This means that the ‘tagsdiv-post_tag’ meta box will be removed from the post edit screen every time the admin menu is loaded.

Overall, the remove_meta_box() function is a handy tool for customizing the WordPress admin interface to suit your specific needs.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.