I want to hide the tag and category boxes from the post editor, the theme I've just developed doesn't need them, thus I want to hide them.
I am aware they could be hidden using the 'screen options' menu, however I'd prefer to do this with a bit of code.
Is this possible?
I want to hide the tag and category boxes from the post editor, the theme I've just developed doesn't need them, thus I want to hide them.
I am aware they could be hidden using the 'screen options' menu, however I'd prefer to do this with a bit of code.
Is this possible?
Share Improve this question asked Aug 2, 2012 at 9:16 Ben EverardBen Everard 1,2885 gold badges19 silver badges34 bronze badges2 Answers
Reset to default 6Using remove metabox
function you can do this. Simply put this inside your themes functions.php
file at very end.
NOTE - unwrap <?php
?>
if necessary.
<?php
function wpse60590_remove_metaboxes() {
remove_meta_box( 'categorydiv' , 'post' , 'normal' );
remove_meta_box( 'tagsdiv-post_tag' , 'post' , 'normal' );
}
add_action( 'admin_menu' , 'wpse60590_remove_metaboxes' );
?>
As @marks-polakovs commented above, this approach doesn't seem to work w/ Gutenberg, and it took me some time to find the following, which does work:
//* Remove default Categories metabox from sidebar in Gutenberg editor
add_action( 'enqueue_block_editor_assets', 'remove_category_panel' );
function remove_category_panel() {
wp_add_inline_script( 'wp-embed', "
wp.data.dispatch( 'core/edit-post' ).removeEditorPanel( 'taxonomy-panel-category' );
" );
}