Skip to content

Instantly share code, notes, and snippets.

@tozbey
Created October 25, 2019 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tozbey/b1aa2cf11a699b72ad390cb5aa749e81 to your computer and use it in GitHub Desktop.
Save tozbey/b1aa2cf11a699b72ad390cb5aa749e81 to your computer and use it in GitHub Desktop.
Hide admin menu items and subitems
/**
* Hide admin menu items. Can be both parents and children in dropdowns.
* Specify link to parent and link to child.
* @link https://codex.wordpress.org/Function_Reference/remove_menu_page
*/
add_action( 'admin_menu', function () {
// Remove Settings
remove_menu_page( 'options-general.php' );
// Remove Settings -> Writing
remove_submenu_page( 'options-general.php', 'options-writing.php' );
// Remove Settings -> Reading
remove_submenu_page( 'options-general.php', 'options-reading.php' );
// Remove Settings -> Discussion
remove_submenu_page( 'options-general.php', 'options-discussion.php' );
// Remove Settings -> Media
remove_submenu_page( 'options-general.php', 'options-media.php' );
// Remove Settings -> Permalinks
remove_submenu_page( 'options-general.php', 'options-permalink.php' );
// Remove Plugins
remove_menu_page( 'plugins.php' );
// Remove Yoast
remove_menu_page( 'wpseo_dashboard' );
}, 999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment