Hiding Metabox from Screen Options Pull Down

  1. I’ve created a Custom Post Type (CPT) which has 2 metaboxes.

  2. On the Edit Page for the CPT, the screen options pull down (at top) displays the metaboxes and gives the user the option to “Show on screen” … or not “Show on screen”.

  3. As these fields are mandatory for the CPT, I would like to hide my metaboxes from the “Screen Options” dropdown completely.

How do I do this?

1 Answer
1

There is no way, at least to my knowledge to unset an option from the screen options panel without unsetting the actual metabox itself.

My suggestion would be to target these screen options item via your CSS and hide it from view.

Add this to your plugin or functions file. Don’t forget to update ‘METABOXIDNAME’ with the ID name of your metabox.

add_action( 'admin_head', 'remove_wordpress_cfields' );

function remove_wordpress_cfields() {
    echo '<style>label[for=METABOXIDNAME-hide] { display: none; }</style>';
} 

Leave a Comment