Change which Meta Boxes are Shown or Hidden by Default

If you want to change what meta boxes are shown and hidden by default instead of trying to walk a client through the process of customizing their own screen, you can use this code as a starting point:

add_filter( 'default_hidden_meta_boxes', 'change_default_hidden', 10, 2 );
function change_default_hidden( $hidden, $screen ) {
    if ( 'page' == $screen->id ) {
        $hidden = array_flip($hidden);
        unset($hidden['authordiv']); //show author box
        $hidden = array_flip($hidden);
        $hidden[] = 'pageparentdiv'; //hide page attributes
    }
    return $hidden;
}

One thought on “Change which Meta Boxes are Shown or Hidden by Default”

Leave a Reply to ThemePrince Cancel reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: