Home > Software engineering >  How do I get rid of the comments dropdown in the WordPress dashboard?
How do I get rid of the comments dropdown in the WordPress dashboard?

Time:01-20

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' );

CodePudding user response:

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.

CodePudding user response:

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

That gets rid of the comments icon.

  •  Tags:  
  • Related