X

How To Remove Meta Boxes From the Post and Page Editors

Snippets by IsItWP

Are you looking for a way to remove meta boxes from the post and page editors? This snippet will remove all of the meta boxes from the post and page editors.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin. Optionally comment out the lines for the meta boxes that you would like to keep.

function remove_meta_boxes() {
  # Removes meta from Posts #
  remove_meta_box('postexcerpt','post','normal' ); 
  remove_meta_box('postcustom','post','normal');
  remove_meta_box('trackbacksdiv','post','normal');
  remove_meta_box('commentstatusdiv','post','normal');
  remove_meta_box('commentsdiv','post','normal');
  # Removes meta from pages #
  remove_meta_box('postexcerpt','page','normal'); // optionally use this if page excerpts are enabled
  remove_meta_box('postcustom','page','normal');
  remove_meta_box('trackbacksdiv','page','normal');
  remove_meta_box('commentstatusdiv','page','normal');
  remove_meta_box('commentsdiv','page','normal');
}
add_action('admin_init','remove_meta_boxes');

To only remove one metabox, use this code. For example, this snippet will removes the Excerpt metabox from the post editor.

 function remove_default_excerpt_metabox() {
 remove_meta_box( 'postexcerpt','post','normal' ); 
 }
 add_action('admin_menu','remove_excerpt_metabox');

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 7 Best Drag and Drop WordPress Page Builders Compared.

Comments   Leave a Reply

  1. Awesome! Just what I was looking for. Thanks!

  2. WordPress 5.1 Support.


    add_action( 'admin_init', 'post_type_support_init' );
    function post_type_support_init() {
    remove_post_type_support( 'page', 'comments' );
    remove_post_type_support( 'post', 'excerpt' );
    remove_post_type_support( 'post', 'author' );
    remove_post_type_support( 'post', 'trackbacks' );
    remove_post_type_support( 'post', 'comments' );
    remove_post_type_support( 'post', 'revisions' );
    remove_post_type_support( 'post', 'post-formats' );
    }

    Reference: https://codex.wordpress.org/Function_Reference/remove_post_type_support

    1. I tried to remove Page Attributes with this code but is not working. Any help please?
      With ‘page’, ‘comments’ is working fine (using Gutenberg editor)

      remove_post_type_support( ‘page’, ‘page-attributes’ );

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!