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?

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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