It’s necessary to allow all users to see less from the admin area so that they can focus only what they are assigned to work on. By default, WordPress provides 10 admin menus to the admin users, 7 for editors, 6 for authors and 2 for subscribers.
In some cases some of the admin menus does not apply to any of the user levels above, for example the admin menu created from Custom Post Types or from plugins, so to minimize the admin area without showing the unneeded menus, we can hook it to the admin_menu
function like below:
function set_admin_menu(){
remove_menu_page( 'edit.php' );
remove_menu_page( 'edit-comments.php' );
}
add_action( 'admin_menu', 'set_admin_menu' );
That will hide the Posts and the Comments menus from the backend area for all users.