Last Updated:

Disable Related Post Plugin Meta Box in Editor

This ‘related post’ plugin adds related articles to the end of your articles. The plugin also allows you to filter articles by type and author by creating a metabox in the backend area.

It may also be useful to disable this functionality if you wish to maintain a clean backend interface for publishing items without too many functions that could confuse the end user.

If you wish, you can disable this functionality for users so that they have the interface unlocked by entering the following code in the functions.php file

if (!current_user_can(‘edit_pages’)){
add_action(‘add_meta_boxes’,‘my_remove_related_post’,100000);
}
function my_remove_related_post(){
remove_meta_boxes(‘related_post’,‘post’,‘normal’);
}
add_action(‘admin_menu’,‘wpdocs_remove_post_custom_fields’);
if(is_admin()){
add_action(‘admin_menu’,‘wpdocs_remove_meta_boxes’);
}

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

The format I have used is also used to remove other functions in the post section, I have written other articles about this.

Avoid using this standard code to hide other metaboxes because it will not work in this case.

function remove_my_post_metaboxes(){
remove_meta_box(‘authordiv’,‘post’,‘normal’);
remove_meta_box(‘commentstatusdiv’,‘post’,‘normal’);
remove_meta_box(‘commentsdiv’,‘post’,‘normal’);
remove_meta_box(‘postcustom’,‘post’,‘normal’);
remove_meta_box(‘postexcerpt’,‘post’,‘normal’);
remove_meta_box(‘revisionsdiv’,‘post’,‘normal’);
remove_meta_box(‘slugdiv’,‘post’,‘normal’);
remove_meta_box(‘trackbacksdiv’,‘post’,‘normal’);
remove_meta_box(‘related_post_metabox’,‘post’,‘high’);
}
add_action(‘admin_menu’,‘remove_my_post_metaboxes’);

I tried this modification with plugin version 2.0.2. Before the change Make sure you make a backup, make sure you know what you are doing right, and make sure the function names do not conflict with other names already in the code.

Use this guide if you know what you are doing, I take no responsibility.