2
  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?

4

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>';
} 
  • 1
    No wonder I couldn't find. Your fix worked like a charm. Thanks again. – sleeper Jun 14 '14 at 19:41
  • 1
    @MattRoyal, I love you man. You saved me so much time. – Greeso May 16 '17 at 1:01
  • 1
    @Greeso, glad I could save you some headaches mate :) – Matt Royal May 16 '17 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.