Remove Menu Items From WordPress Admin Bar
Ever want to remove items from the WordPress Admin Bar? If yes – there is a simple way to handle this using a few steps:
- Identify what you want to remove.
- View the page source and find the CSS ID of the item you want to remove (see screenshot). Note whatever comes after “wp-admin-bar-“. Example: wp-admin-bar-dashboard – you would note “dashboard”
- Add the following code into your theme’s functions.php file and customize the “CSS ID” that you want to remove. (The example below will remove the dashboard link)
/**
* Remove Dashboard Link for subscribers
*
*/
add_action( 'wp_before_admin_bar_render', 'sdac_custom_admin_bar' );
function sdac_custom_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('dashboard');
}
