How to remove the Glossary plugin meta box from the post editing panel

Glossary, is a plugin that allows you to create a glossary of terms. It is a very complete software, it also allows you to create external and internal links to the site without necessarily creating an attached article. This plugin in the post edit section creates a metabox. Someone may need to remove it for several reasons.

It is sufficient to add the following code at the bottom of the functions.php.

// remove glossary_post_metabox
if ( ! current_user_can( 'edit_pages' ) ) {
add_action( 'add_meta_boxes', 'my_remove_glossary_post_metabox', 100000 );
}
function my_remove_glossary_post_metabox(){
remove_meta_box( 'glossary_post_metabox', 'post', 'normal' );
}
add_action( 'admin_menu' , 'wpdocs_remove_post_custom_fields' );
if ( is_admin() ) {
add_action( 'admin_menu', 'wpdocs_remove_meta_boxes' );
}

I suggest you create a child theme where to put this code. Any subsequent updates may overwrite the code.

The format I used also serves to remove other features in the posts section, I’ve written other articles that talk about it.

Avoid using the standard system with such a code or there will be problems:

function remove_my_post_metaboxes() {
remove_meta_box( 'authordiv','post','normal' ); // Author Metabox
remove_meta_box( 'commentstatusdiv','post','normal' ); // Comments Status Metabox
remove_meta_box( 'commentsdiv','post','normal' ); // Comments Metabox
remove_meta_box( 'postcustom','post','normal' ); // Custom Fields Metabox
remove_meta_box( 'postexcerpt','post','normal' ); // Excerpt Metabox
remove_meta_box( 'revisionsdiv','post','normal' ); // Revisions Metabox
remove_meta_box( 'slugdiv','post','normal' ); // Slug Metabox
remove_meta_box( 'trackbacksdiv','post','normal' ); // Trackback Metabox
remove_meta_box( 'related_post_metabox','post','high' ); // Trackback Metabox
}
add_action('admin_menu','remove_my_post_metaboxes');

I tested this change with the 1.4.11 plugin version. Before editing Make sure you make a backup, make sure you know what you are doing well and make sure the function names do not conflict with other names already in the code.

Rispondi