ControlledChaos of Controlled Chaos Design
8/9/2016 - 6:44 PM

Hide WordPress meta boxes in post editor.

Hide WordPress meta boxes in post editor.

<?php

add_action( 'default_hidden_meta_boxes', 'ccd_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 ccd_remove_meta_boxes( $hidden, $screen ) {
	if ( 'acme_post_type' == $screen->id ) {
		$hidden = array(
			'acme_post_type_categorydiv',
			'authordiv',
			'postexcerpt',
			'slugdiv'
    );
	}
	return $hidden;
}

?>

Hide WP Meta Boxes

WordPress Snippet

Parameters

$id (string) (required) Value of the id attribute of the HTML element to remove. Some of the available id values are given below:

'authordiv' – Author metabox 'categorydiv' – Categories metabox. 'commentstatusdiv' – Comments status metabox (discussion) 'commentsdiv' – Comments metabox 'formatdiv' – Formats metabox 'pageparentdiv' – Attributes metabox 'postcustom' – Custom fields metabox 'postexcerpt' – Excerpt metabox 'postimagediv' – Featured image metabox 'revisionsdiv' – Revisions metabox 'slugdiv' – Slug metabox 'submitdiv' – Date, status, and update/save metabox 'tagsdiv-post_tag' – Tags metabox '{$tax-name}div' - Hierarchical custom taxonomies metabox 'trackbacksdiv' – Trackbacks metabox ...

Default: None

$page (string) (required) Type of the screen to remove the meta box from, such as:

'post' 'page' 'attachment' 'link' 'dashboard' or any registered custom post type, e.g. 'my-product'

Default: None

$context (string) (required) 'normal', 'advanced', or 'side'.

Default: None