skip to Main Content

The code below removes everything I want except for the comments dropdown.

enter image description here

That pesky little icon just won’t go away. Is there another method?

// Remove Admin bar links
function remove_admin_bar_links() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');          // Remove the WordPress logo
    $wp_admin_bar->remove_menu('about');            // Remove the about WordPress link
    $wp_admin_bar->remove_menu('wporg');            // Remove the WordPress.org link
    $wp_admin_bar->remove_menu('documentation');    // Remove the WordPress documentation link
    $wp_admin_bar->remove_menu('support-forums');   // Remove the support forums link
    $wp_admin_bar->remove_menu('feedback');         // Remove the feedback link
    $wp_admin_bar->remove_menu('comments');         // Remove the comments link
    $wp_admin_bar->remove_menu('new-content');      // Remove the content link
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

2

Answers


  1. Chosen as BEST ANSWER

    Figured out I have to add: $wp_admin_bar->remove_menu('notes');

    That gets rid of the comments icon.


  2. You can use:

    function remove_toolbar_node(WP_Admin_Bar $wp_admin_bar) {
        $wp_admin_bar->remove_node('comments');
    }
    add_action('admin_bar_menu', 'remove_toolbar_node', 999);
    

    Note that you can use $wp_admin_bar->get_nodes() to get available nodes.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search