Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WordPress] Using the default_hidden_meta_boxes hook to remove meta boxes from the dashboard of a custom post type.
<?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
You can’t perform that action at this time.