FUNCTIONING CODE AS OF WORDPRESS 5.7+, AUGUST 2021
I needed to customize the WP admin bar for a large WP site we are working on (text was running off the admin bar when resizing). I tried literally every snippet of code from all the previous answers to this question; unfortunately none worked for me. This code I found off Google did, so I wanted to share with others (goes in your functions.php):
/**
* This function removes items from the WP admin bar. If it gets too cluttered,
* things will run off the screen and look bad.
* @param object $wp_admin_bar representing the WP admin bar.
*/
function remove_from_admin_bar($wp_admin_bar) {
// WordPress Core Items (uncomment to remove)
$wp_admin_bar->remove_node('updates');
$wp_admin_bar->remove_node('comments');
//wp_admin_bar->remove_node('new-content');
$wp_admin_bar->remove_node('wp-logo');
//$wp_admin_bar->remove_node('site-name');
//$wp_admin_bar->remove_node('my-account');
//$wp_admin_bar->remove_node('search');
$wp_admin_bar->remove_node('customize');
}
add_action('admin_bar_menu', 'remove_from_admin_bar', 999);
I think a great start is to remove the comments, updates, and WP icon. Custom plugins can be disabled here, too. The 999 indicates when the hook will fire off later. You can wrap elements in the is_admin()
function if you want to hide or show different links on the front end vs. the WP admin.