Are you looking for a way to disable submenu items from the Admin menu? This snippet disables submenus, like Themes and Writing, from the Admin menu.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin. Optionally add more lines to remove other submenu items. You can find more menu IDs in the wp-admin/menu.php
file.
function remove_submenus() { global $submenu; unset($submenu['index.php'][10]); // Removes 'Updates'. unset($submenu['themes.php'][5]); // Removes 'Themes'. unset($submenu['options-general.php'][15]); // Removes 'Writing'. unset($submenu['options-general.php'][25]); // Removes 'Discussion'. } add_action('admin_menu', 'remove_submenus');
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: How to Properly Create a Custom Login Page in WordPress (Step by Step).
Comments Leave a Reply