The remove_menu_page() WordPress PHP function removes a top-level admin menu.
Usage
remove_menu_page('tools.php'); remove_menu_page('plugin_menu_slug');
Parameters
$menu_slug
(string) – Required. The slug of the menu.
More information
See WordPress Developer Resources: remove_menu_page()
Examples
Remove the Tools menu
Remove the Tools menu from the admin dashboard.
add_action('admin_menu', 'remove_tools_menu'); function remove_tools_menu() { remove_menu_page('tools.php'); }
Remove the Media menu
Remove the Media menu from the admin dashboard.
add_action('admin_menu', 'remove_media_menu'); function remove_media_menu() { remove_menu_page('upload.php'); }
Remove the Plugins menu
Remove the Plugins menu from the admin dashboard.
add_action('admin_menu', 'remove_plugins_menu'); function remove_plugins_menu() { remove_menu_page('plugins.php'); }
Remove the Comments menu
Remove the Comments menu from the admin dashboard.
add_action('admin_menu', 'remove_comments_menu'); function remove_comments_menu() { remove_menu_page('edit-comments.php'); }
Remove multiple menus
Remove multiple menus from the admin dashboard at once.
add_action('admin_menu', 'remove_multiple_menus'); function remove_multiple_menus() { remove_menu_page('edit.php'); remove_menu_page('upload.php'); remove_menu_page('edit-comments.php'); }