Skip to content

Instantly share code, notes, and snippets.

@kasng
Created September 28, 2016 03:26
Show Gist options
  • Save kasng/a6da6aa37f334d8be72313945a39bf67 to your computer and use it in GitHub Desktop.
Save kasng/a6da6aa37f334d8be72313945a39bf67 to your computer and use it in GitHub Desktop.
Hide all meta boxes in post type
<?php
/**
* Hide all metaboxes in the global $wp_meta_boxes
*/
add_filter( 'hidden_meta_boxes', function( $hidden, $screen, $use_defaults )
{
global $wp_meta_boxes;
$cpt = 'post'; // Modify this to your needs!
if( $cpt === $screen->id && isset( $wp_meta_boxes[$cpt] ) )
{
$tmp = array();
foreach( (array) $wp_meta_boxes[$cpt] as $context_key => $context_item )
{
foreach( $context_item as $priority_key => $priority_item )
{
foreach( $priority_item as $metabox_key => $metabox_item )
$tmp[] = $metabox_key;
}
}
$hidden = $tmp; // Override the current user option here.
}
return $hidden;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment