WordPress, how to remove the meta box of the plugin related post from the post editing panel

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

It can also be useful to disable this feature if you want to maintain a backend interface for publishing clean items and without too many features that might confuse the end user.

If you want you can disable this feature 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_remove_related_post(){
remove_meta_box('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 you create a child theme where you put this code. Subsequent updates may overwrite the code.

The format I used also serves to remove other features in the post section, I wrote other articles about it.

Avoid using this standard code to hide other metaboxes because it won’t 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 change with the plugin version 2.0.2. Before you change Make sure you make a backup, make sure you know what you’re doing well, and make sure that function names don’t conflict with other names already in your code.

Use this guide if you know what you’re doing, I don’t take any responsibility.


It's possible to leave a comment as registered users to the site, accessing through social, wordpress account or as anonymous users. If you want to leave a comment as an anonymous user you will be notified by email of a possible response only if you enter the email address (optional). The insertion of any data in the comment fields is totally optional. Whoever decides to insert any data accepts the treatment of these last ones for the inherent purposes of the service that is the answer to the comment and the strictly necessary communications.


Leave a Reply