The WordPress post page (where you write your posts) can get a little crowded for some people’s taste.

For example, take a look at this screenshot of the section below the write/edit screen. It’s jam-packed with different types of meta boxes.

Of course if you want to remove a lot of that messiness, you can pull down the Screen Options panel at the top of the page and uncheck whatever you like.

While that works, you might have a situation where you want all of those meta boxes removed automatically. Maybe you’re dealing with clients or site users who don’t need to learn yet another little something they have to do. Or maybe you don’t want those boxes available to them regardless.

While there are a number of plugins that will do this for you, in this post, we’re going to show you how you can do that by placing some code in your functions.php file.

Code for Removing Meta Boxes

The code below has comments in it, so you can add or remove whatever you like. For example, if you’d like to keep the excerpts meta box, then you should be able to easily identify the line that applies to excerpts and take that line out.

Place the following code in your functions file (Appearance > Editor > Theme Functions – functions.php).

// REMOVE POST META BOXES
function remove_my_post_metaboxes() {
remove_meta_box( 'authordiv','post','normal' ); // Author Metabox
remove_meta_box( 'commentstatusdiv','post','normal' ); // Comments Status Metabox
remove_meta_box( 'commentsdiv','post','normal' ); // Comments Metabox
remove_meta_box( 'postcustom','post','normal' ); // Custom Fields Metabox
remove_meta_box( 'postexcerpt','post','normal' ); // Excerpt Metabox
remove_meta_box( 'revisionsdiv','post','normal' ); // Revisions Metabox
remove_meta_box( 'slugdiv','post','normal' ); // Slug Metabox
remove_meta_box( 'trackbacksdiv','post','normal' ); // Trackback Metabox
}
add_action('admin_menu','remove_my_post_metaboxes');

Placing that code should remove all the meta boxes below the post editor and give you a nice, clean look. The yellow outline is where all the meta boxes used to be.

Of course those boxes under the post editor aren’t the only meta boxes on that screen. There are also the more important meta boxes to the right of the editor

There is code to remove those too, but we’ll separate it out here because it’s less likely that people would want those boxes removed. If you do, however, you’d simply need to copy and paste whichever line you’d like into the lines of code above. (The one meta box that many may want to get rid of here is the Formats box.)

 remove_meta_box( 'categorydiv','post','normal' ); // Categories Metabox
remove_meta_box( 'formatdiv','post','normal' ); // Formats Metabox
remove_meta_box( 'postimagediv','post','normal' ); // Featured Image Metabox
remove_meta_box( 'submitdiv','post','normal' ); // Categories Metabox
remove_meta_box( 'tagsdiv-post_tag','post','normal' ); // Tags Metabox

*Note: the code for removing the Featured Image meta box doesn’t seem to work (and hasn’t for a while for some reason), and so we haven’t included it here.

Remove Meta Boxes from Pages

The same can be done for Pages, of course. Here’s the code for that.

/ REMOVE PAGE META BOXES
function remove_my_page_metaboxes() {
remove_meta_box( 'postcustom','page','normal' ); // Custom Fields Metabox
remove_meta_box( 'postexcerpt','page','normal' ); // Excerpt Metabox
remove_meta_box( 'commentstatusdiv','page','normal' ); // Comments Metabox
remove_meta_box( 'trackbacksdiv','page','normal' ); // Talkback Metabox
remove_meta_box( 'slugdiv','page','normal' ); // Slug Metabox
remove_meta_box( 'authordiv','page','normal' ); // Author Metabox
}
add_action('admin_menu','remove_my_page_metaboxes');

Remember that when you put this code in your functions.php file, it’s theme-specific. So if you change themes, you’ll need to do it for that functions file too.

HOW TO FIND DIV NAME ??

To find meta box name, inspect element and find the div id of the corresponding div

LEAVE A REPLY

Please enter your comment!
Please enter your name here