In the post editor or page editor, even the admin dashboard, there are different meta boxes 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.
Method 1: Use Code to Remove Unwanted Meta Boxes in WordPress
WordPress has the remove_meta_box
function for doing this. Here is its structure:
remove_meta_box( string $id, string|array|WP_Screen $screen, string $context )
You can read more about the parameters of this function for more details here.
For example, in the post editor section, there is a default meta box named Custom Fields.
I will add the below code to the function.php
file to remove this meta box:
add_action( 'admin_menu', function() { remove_meta_box( 'postcustom', 'post', 'normal' ); } );
Then, it'll be no longer there:
Another example, 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:
add_action( 'wp_dashboard_setup', function() { remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); } );
Then, the Dashboard becomes tidier.
Method 2: Use a Plugin to Remove Unwanted Meta Boxes in WordPress
There are many plugins for removing meta boxes. I've tried some of them and find Adminimize to be a good choice.
The Adminimize plugin is free and available on wordpress.org.
After installing the plugin, go to Settings > Adminimize. In this section, you will see that it provides many features, not only removing meta boxes.
Go to Write options - Post section to deactivate the meta boxes from the post editor in Post. If you want to remove the meta box in other post types, choose Write options - [post type].
As you can see, this plugin allows you only to deactivate meta boxes, not completely delete them as the using code method. But the special feature of this plugin is that you can deactivate each type of meta box for different user roles. Thus, you can restrict users to view meta boxes to prevent them from changing information.
Last Words
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 Adminimize also helps you customize the appearance of others in the admin bar, backend options, plugin settings,... You should dig into it to take more advantage of it.
On the contrary, in case you want to create new meta boxes for extra information for posts, pages, users, settings page, you may want to refer to these articles on how to create meta boxes without plugin, or how to do the same work with the Meta Box plugin.