How to Remove WordPress Plugin’s Metabox on Products, Post & Page Editor

How to Remove WordPress Plugin’s Metabox on Products, Post & Page Editor

Metabox adds a user friendly interface for you to interact with post metadata. In other words, it is some sort of additional options or settings that can be added to original WordPress post, page, Woocommerce product, and also other custom post type.

For example; if you’re using any SEO plugin such as Yoast or AIO Seo, these plugin will automatically add additional settings on your page & post backend editing view so that you can easily customize or override the seo title & description for each page or post. This is a good feature if you need a full control what will be displayed on SERP of each and every single post or page or even product.

For us, usually we will leave the SEO stuffs to automatically use the default post title and get the description from the post excerpt or content unless SEO Optimization work needed by client request. And yes, of course we do need these plugins to run on their standard settings but their SEO Option Metabox will be there on each page/post by default. Since most of the end users are not really using it, this metabox will make the editing page looks a bit cluttered while taking too much space. So it is far better to leave it hidden by default for all user – less clutter and neat editing page.

3 Ways to Hide WordPress Metaboxes & the one created by Plugins

  1. Metaboxes created by plugins usually can be enable or disable via their plugin’s settings page. But most plugins do not have this feature.
  2. We can go to each page/post/product editing page and set the metaboxes hidden via the top right “Screen Options” menu. But the problem is this has to be done for each users onsite. Duh!
  3. The most efficient way is to remove all the unwanted metaboxes using filters in your theme’s functions.php. This will remove the metabox from everyone view and removed them from the “Screen Options” menu item as well. On most cases, default WordPress metaboxes and metaboxes created by plugins can be removed from user views. We will explain how to implement this 3rd method in this tutorial.

Remove Metaboxes using WordPress Function

First step is we need to enable all available metaboxes via the Screen Options on each post type (Post Type refers to Post, Page, Product editing page).

Then we have to identify the metaboxes that need to be removed and their current default location. Metabox location consists of “normal” and “side”. Normal refers to the same column as the Post Title & Content Editor area. Example Metabox in Normal location: WP Bakery Page Builder, Yoast, Post Option, Discussion, Review, etc. Side refers to the side column same as Publishing button. Example Metabox in Side location: Format, Categories, Feature Image, Product Brands, etc.

Once we have take note on the default metaboxes location, now we need to identify the metabox’s div ID. To do this we use the Google Chrome or Firefox inspect tool. Simply Right Click on the metabox’s title, then select Inspect Element to open up to dev console. In the console, go up 2-3 lines to get the main div ID that holds the whole box area. Each metabox has their own unique div ID. Check the example below for All in One SEO page metabox ID “aiosp_tabbed”.

How to remove SEO Metabox

 

Take note on the metabox ID and now it’s time to add in our remove_metabox function in the theme’s functions.php file.
The basic function needed:

//remove product-page-post metaboxes
function remove_metaboxes() {
     remove_meta_box( 'aiosp_tabbed' , 'product' , 'normal' );
     remove_meta_box( 'aiosp_tabbed' , 'page' , 'normal' );
     remove_meta_box( 'aiosp_tabbed' , 'post' , 'normal' );
}
add_action( 'add_meta_boxes' , 'remove_metaboxes', 50 );

Explanation of the parameter used in the above function:

1st parameter = the metabox div ID we obtained from code inspector. Example: ‘aiosp_tabbed’
2nd parameter = the post type editing view. Example: ‘product’ is for Woocommerce product editing page.
3rd parameter = the default original location of the metabox. Example: ‘normal’ due to the AIO metabox located under same column as content editor. Some reference here.

We have also removed few other unwanted metaboxes to make the editing view looks less cluttered for our clients so that they only be able to edit only what is needed/allowed and also to avoid confusion due to too many items on screen. After adding few more lines, the result will be like below.

Hide Woocommerce unwanted metabox

 

Our full metaboxes removal function looks like this:

//remove product-page-post metaboxes
function remove_metaboxes() {
     remove_meta_box( 'postcustom' , 'product' , 'normal' ); //for Woo Product
//   remove_meta_box( 'postexcerpt' , 'product' , 'normal' );
//     remove_meta_box( 'tagsdiv-product_tag','product','side' );
     remove_meta_box( 'sw_page_meta' , 'product' , 'normal' );
     remove_meta_box( 'aiosp_tabbed' , 'product' , 'normal' );
     remove_meta_box( 'sw_product_video_meta' , 'product' , 'side' );
     remove_meta_box( 'sw_product_meta' , 'product' , 'side' );
     remove_meta_box( 'slugdiv' , 'product' , 'normal' );
     remove_meta_box( 'postcustom' , 'page' , 'normal' ); //for All Page
     remove_meta_box( 'A2A_SHARE_SAVE_meta' , 'page' , 'side' );
     remove_meta_box( 'slugdiv' , 'page' , 'normal' );
     remove_meta_box( 'authordiv' , 'page' , 'normal' );
     remove_meta_box( 'sw_page_meta' , 'page' , 'normal' );
     remove_meta_box( 'aiosp_tabbed' , 'page' , 'normal' );
     remove_meta_box( 'commentsdiv' , 'page' , 'normal' );
     remove_meta_box( 'commentstatusdiv' , 'page' , 'normal' );
     remove_meta_box( 'postcustom' , 'post' , 'normal' ); //for All Post
     remove_meta_box( 'A2A_SHARE_SAVE_meta' , 'post' , 'side' );
     remove_meta_box( 'slugdiv' , 'post' , 'normal' );
     remove_meta_box( 'authordiv' , 'post' , 'normal' );
     remove_meta_box( 'sw_page_meta' , 'post' , 'normal' );
     remove_meta_box( 'aiosp_tabbed' , 'post' , 'normal' );
     remove_meta_box( 'commentsdiv' , 'post' , 'normal' );
     remove_meta_box( 'commentstatusdiv' , 'post' , 'normal' );
     remove_meta_box( 'trackbacksdiv' , 'post' , 'normal' );
}
add_action( 'add_meta_boxes' , 'remove_metaboxes', 50 );

The above codes include metaboxes created by the theme & other plugins plus some default wordpress metaboxes.

Here we would like to share some metabox IDs from wordpress default and popular plugins.

  • aiosp_tabbed , normal – All In One SEO Pack metabox
  • slugdiv , normal – WP slug metabox
  • trackbacksdiv , normal – WP post trackback metabox
  • commentsdiv , normal – WP comment metabox
  • wpseo_meta , normal – Yoast SEO metabox
  • wc-jetpack-purchase_data , normal – Booster for WC : Cost of Goods metabox
  • rocket_post_exclude , side – WP Rocket metabox
  • mymetabox_revslider_0 , normal – Revolutions Slider Option metabox
  • woocommerce-product-images , side – WooCommerce default Product Gallery metabox
  • tagsdiv-product_tag , side – WC default product tag metabox

By the way, the above methods is tested on current WordPress version 5.1.1 and all updated plugins to date. Plugin’s metabox ID may changes after updates.

Hope this tutorial will help everyone out there who is looking for a similar solution. If you have any opinion, simply leave your comment below and if you do need onsite assistance, our WordPress Engineer will always available for any customization work. Please contact us at hello@ewallzsolutions.com of fill in the contact form.

Share this post


Open chat
Powered by