apply_filters( ‘default_hidden_meta_boxes’, string[] $hidden, WP_Screen $screen )

Filters the default list of hidden meta boxes.

Parameters

$hiddenstring[]
An array of IDs of meta boxes hidden by default.
$screenWP_Screen
WP_Screen object of the current screen.

Source

$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );

Changelog

VersionDescription
3.1.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    This filter is used to hide metabox by default, an admin user can then select the ‘Screen Options’ tab in the top right hand corner of the post edit screen and they will see the designated ‘hidden’ metaboxes checked in the list of options,

    add_filter('default_hidden_meta_boxes','hide_meta_box',10,2);
    function hide_meta_box($hidden, $screen) {
        //make sure we are dealing with the correct screen
        if ( ('post' == $screen->base) && ('my-custom-post_type' == $screen->id) ){
          //lets hide everything
          $hidden = array('postexcerpt','slugdiv','postcustom','trackbacksdiv', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
          $hidden[] ='my_custom_meta_box';//for custom meta box, enter the id used in the add_meta_box() function.
        }
        return $hidden;
      }

You must log in before being able to contribute a note or feedback.