How to Remove WordPress Post Meta Boxes

WordPress is a content management system. Currently, 29.1% of websites run on WordPress. Currently, WordPress is the most popular open-source Content Management System (CMS).

You can do virtually anything using WordPress, provided you have the proper knowledge. It is important to reduce clutter on your WordPress site because it improves the overall user experience, which is vital for your site’s reputation.

What are Meta Boxes?

In the post edit screen in WordPress, you will find some draggable boxes, containing meta details for your post. On your dashboard, there are widgets present, and these are also considered meta boxes.

You do not want your viewers to see too many boxes cluttered on the screen, because it can be distracting. You want them concentrating on your content. So you should learn how to Remove WordPress Post Meta Boxes to free up space and remove irrelevant information.

WordPress Post Meta Boxes

Removing the Boxes

Let us take a look at the different ways we can Remove WordPress Post Meta Boxes:

  • Removing a single box: Use this code to remove a single meta box. For this purpose, we have named the box as abcd. This code will remove the abcd box from the post editor.function
    remove_default_abcd_metabox() {
    remove_meta_box( ‘postabcd’,’post’,’normal’ );
    }
    add_action(‘admin_menu’,’remove_abcd_metabox’);
  • Removing multiple boxes: One can Remove WordPress Post Meta Boxes using JavaScript. But hiding the boxes using JavaScript can prove to be problematic because visibility of elements is usually configured using CSS, and it might cause a flickering effect.

    Some developers trigger the click event of the checkboxes under Screen Options. Others use the hide() method of jQuery to hide the meta boxes. However, there exists a more efficient way to do this using function that accepts two arguments, namely the current screen and the list of meta boxes that should be hidden.

    Here, we will take the post type as abcd_post_type and we will hide the Author, Slug, Post excerpt and Categories meta boxes.<?php
    add_action( ‘default_hidden_meta_boxes’, ‘abcd_remove_meta_boxes’, 10, 2 );
    /**
    * @since 1.0.0
    *
    * @param array $hidden The array of meta boxes that should be hidden for Acme Post Types
    * @param object $screen The current screen object that’s being displayed on the screen
    * @return array $hidden The updated array that removes other meta boxes
    */
    function abcd_remove_meta_boxes( $hidden, $screen ) {
    if ( ‘abcd_post_type’ == $screen->id ) {
    $hidden = array(
    ‘abcd_post_type_categorydiv’,
    ‘authordiv’,
    ‘postexcerpt’,
    ‘slugdiv’
    );
    }
    return $hidden;
    }
    The code first checks the screen we are at. If we are on the screen for the custom post type, a new array is defined. The IDs of all the meta boxes are present in this array. Then the new array is added to WordPress and the specified meta boxes are removed.

  • Removing meta boxes for non-admins: To Remove WordPress Post Meta Boxes for individuals who are not admins, use the following code:if (is_admin()) :
    function remove_post_meta_boxes() {
    if(!current_user_can(‘administrator’)) {
    remove_meta_box(‘tagsdiv-post_tag’, ‘post’, ‘normal’);
    remove_meta_box(‘categorydiv’, ‘post’, ‘normal’);
    remove_meta_box(‘postimagediv’, ‘post’, ‘normal’);
    remove_meta_box(‘authordiv’, ‘post’, ‘normal’);
    remove_meta_box(‘postexcerpt’, ‘post’, ‘normal’);
    remove_meta_box(‘trackbacksdiv’, ‘post’, ‘normal’);
    remove_meta_box(‘commentstatusdiv’, ‘post’, ‘normal’);
    remove_meta_box(‘postcustom’, ‘post’, ‘normal’);
    remove_meta_box(‘commentstatusdiv’, ‘post’, ‘normal’);
    remove_meta_box(‘commentsdiv’, ‘post’, ‘normal’);
    remove_meta_box(‘revisionsdiv’, ‘post’, ‘normal’);
    remove_meta_box(‘authordiv’, ‘post’, ‘normal’);
    remove_meta_box(‘slugdiv’, ‘post’, ‘normal’);
    }
    }
    add_action( ‘admin_menu’, ‘remove_post_meta_boxes’ );
    endif;

meta boxes

Related Post: How to remove and troubleshoot all the WordPress common errors

About Sonnal S Sinha

Sonnal S SinhaSonnal S Sinha is a passionate writer as well as WordPress and WooCommerce rockstar who loves to share insights on various topics through his engaging blog posts. He runs a successful website design and digital marketing company. With 15+ years of experience in WordPress theme development, he strives to inform and inspire readers with his thought-provoking content. He helps thousands of small and medium businesses and startups create a unique online presence. Follow Sonnal S Sinha for your regular dose of knowledge and inspiration.

Do check out our free WordPress themes and WordPress themes bundle