-
-
Save tommcfarlin/07a77449f7c768ecbbf2 to your computer and use it in GitHub Desktop.
[WordPress] Using the default_hidden_meta_boxes hook to remove meta boxes from the dashboard of a custom post type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'default_hidden_meta_boxes', 'acme_remove_meta_boxes', 10, 2 ); | |
/** | |
* Removes the category, author, post excerpt, and slug meta boxes. | |
* | |
* @since 1.0.0 | |
* | |
* @param array $hidden The array of meta boxes that should be hidden for Acme Post Types | |
* @param object $screen The current screen object that's being displayed on the screen | |
* @return array $hidden The updated array that removes other meta boxes | |
*/ | |
function acme_remove_meta_boxes( $hidden, $screen ) { | |
if ( 'acme_post_type' == $screen->id ) { | |
$hidden = array( | |
'acme_post_type_categorydiv', | |
'authordiv', | |
'postexcerpt', | |
'slugdiv' | |
); | |
} | |
return $hidden; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the tip, but I would rather use
hidden_meta_boxes
filter instead asdefault_hidden_meta_boxes
might not be triggered depending on your settings.