How to Remove Unwanted Meta Boxes in WordPress
Tags: wordpress, tutorial
Published: 2021-05-26 12:56:21

In the post editor or page editor, even admin dashboard, there are different <a href="https://metabox.io/how-to-create-custom-meta-boxes-custom-fields-in-wordpress/#what-is-meta-box">meta boxes</a> available. Perhaps, some of them are unused and you want to remove them to make your working screen clearer. It helps you to concentrate on the main contents better. Let's learn how to remove unwanted meta boxes in WordPress.

You can use code or plugin as follows.

<!--more-->

<h2>Method 1: Use Code to Remove Unwanted Meta Boxes in WordPress</h2>

WordPress has the <code>remove_meta_box</code> function for doing this. Here is its structure:

<pre>remove_meta_box( string $id, string|array|WP_Screen $screen, string $context )

</pre>

You can read more about the parameters of the above function <a href="https://developer.wordpress.org/reference/functions/remove_meta_box/">here</a>.

For example, in the <strong>post editor</strong> section, there is a default meta box named <strong>Custom Fields</strong>.

<img class="aligncenter" src="https://i.imgur.com/tfuSpax.png" alt="There is a default meta box named Custom Fields" />

I will add the below code in the <code>function.php</code> file to remove this meta box:

<pre>add_action( 'admin_menu', function() {

    remove_meta_box( 'postcustom', 'post', 'normal' );

} );

</pre>

Then, it is no longer there:

<strong><img class="aligncenter" src="https://i.imgur.com/5hIsuei.png" alt="Insert code in the function.php file to remove this meta box." /></strong>

Another example, there are many different meta boxes to display general website information or shortcuts in the <strong>Admin Dashboard</strong>:

<img class="aligncenter" src="https://i.imgur.com/x6LrT83.png" alt="There are many different meta boxes to display general website information or shortcuts in the Admin Dashboard" />

I will try removing them with the below code:

<pre>add_action( 'wp_dashboard_setup', function() {

    remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );

    remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );

} );

</pre>

Then, the <strong>Dashboard</strong> becomes tidier.

<img class="aligncenter" src="https://i.imgur.com/uqIsm6h.png" alt="Result of removing meta boxes from the Dashboard." />

<h2>Method 2: Use a Plugin to Remove Unwanted Meta Boxes in WordPress</h2>

There are many plugins for removing meta boxes. I've tried some of them and find <strong>Adminimize</strong> to be a good choice.

The <strong>Adminimize</strong> plugin is free and available on <a href="https://wordpress.org/plugins/adminimize/">wordpress.org</a>.

<span style="font-weight: 400;">[wp-pic type="plugin" slug="adminimize" layout="large" ]</span>

After installing the plugin, go to <strong>Settings &gt; Adminimize</strong>. In this section, you will see that it provides many features, not only removing meta boxes.

<img class="aligncenter" src="https://i.imgur.com/NsVex3N.png" alt="After installing the plugin, go to Settings &gt; Adminimize." />

Go to <strong>Write options - Post</strong> to deactivate the meta boxes from the post editor in <strong>Post</strong>. If you want to remove the meta box in other post types, choose <strong>Write options - [post type]</strong>.

<img class="aligncenter" src="https://i.imgur.com/EjLpAMH.png" alt="This plugin allows you only to deactivate meta boxes, not completely delete them as using code" />

As you can see, this plugin allows you only to deactivate meta boxes, not completely delete them as using code. But the special feature of this plugin is that you can deactivate each type of meta boxes for different user rolls. Thus, you can restrict users to view meta boxes to prevent them from changing information.

<h2>Last Words</h2>

If you want to remove meta boxes completely so that no one can find them, using code is the better choice. If you want to authorize each user role to view just some kinds of them, using a plugin is perfect. Both of them are simple and quick.

One more thing, using plugin <strong>Adminimize</strong> also helps you customize the appearance of others in the admin bar, backend options, plugin settings,... You should dig in it to take more advantages from it.

If you have other ideas, please share with us in the below comment box.