Remove Meta Box Added by Plugin Via Your Child Theme

This code enables you to remove unwanted meta boxes which are added by plugins. Use this code in your child themes functions file or custom functions/code snippets plugin.

add_action('add_meta_boxes', 'remove_monsterinsights_metabox', 100);
function remove_monsterinsights_metabox() {

    remove_meta_box('monsterinsights-metabox', null, 'side');
    
}

Code Settings

The code uses the remove_meta_box function and 3 parameters.

  1. $id
  2. $screen
  3. $context

You’ll need to find the original add_meta_box function in your plugin to find these required values.

In this example, we find the following function in the plugin which is :

function create_meta_box() {
    add_meta_box(
    'monsterinsights-metabox',
    'MonsterInsights',
    [ $this, 'print_metabox_html' ],
    null,
    'side',
    'high'
    );
}

From this code we get the values for the 3 parameters we need to remove the meta box :

  1. monsterinsights-metabox
  2. null
  3. side
remove_meta_box('monsterinsights-metabox', null, 'side');

Regardless of how the meta box has been added, by plugin OOP ( PHP class ) or your parent theme, this code added to the end of your child themes functions file will remove the box even after plugin or parent themes updates.

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.