How to change Default Screen Options in WordPress

I’m looking for a way to change the default screen options in the post editor.
I want to hide certain options by default. I am putting together a family recipe site and don’t want to overwhelm users with too many options. I don’t want to log in as each user and changing their options manually. I’ve combed through WP core files and theme files and can’t find very many references to screen-options. Is it defined somewhere in the database?

Thanks in advance.

Related posts

Leave a Reply

3 comments

  1. Use the default_hidden_meta_boxes filter

    add_filter( 'default_hidden_meta_boxes', 'my_hidden_meta_boxes', 10, 2 );
    function my_hidden_meta_boxes( $hidden, $screen ) {
        return array( 'tagsdiv-post_tag', 'tagsdiv', 'postimagediv', 'formatdiv', 'pageparentdiv', ''); // get these from the css class
    }
    

    or

    add_filter( 'hidden_meta_boxes', 'my_hidden_meta_boxes', 10, 2 );
    

    Bonus: To understand how it works have a look at the core function get_hidden_meta_boxes(). Here’s a simplified version:

    function get_hidden_meta_boxes( $screen ) {
        $hidden = get_user_option( "metaboxhidden_{$screen->id}" );
        if ( $use_defaults ) {
            $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
        }
        return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
    }
    
  2. A slight modification to Zendka’s answer. I just wanted to remove one item from the list, leaving the array otherwise unchanged.

    add_filter( 'default_hidden_meta_boxes', 'show_author_metabox', 10, 2 );
    function show_author_metabox( $hidden, $screen )
    {
        $authorkey = array_search( 'authordiv', $hidden );
        unset( $hidden[ $authorkey ] );
    
        return $hidden;
    }
    

    In my case I was removing the ‘authordiv’ from the hidden list, swap that out with whatever metabox you want to remove from the hidden meta boxes.

    I don’t check for the existence of the metabox before unsetting it, because it doesn’t produce any PHP notices/errors if there are no results from the array_search.