Remove Items From the Admin Bar
Removes admin bar entries you never use, such as Comments, "+ New", Customize or Search.
Opens WPIDE on
Code
// Node IDs to remove. Common ones: comments, new-content, customize, search, updates, edit, site-editor.
$wpide_admin_bar_remove = array( 'comments', 'new-content', 'customize', 'search' );
add_action( 'admin_bar_menu', function ( $wp_admin_bar ) use ( $wpide_admin_bar_remove ) {
foreach ( $wpide_admin_bar_remove as $node_id ) {
$wp_admin_bar->remove_node( $node_id );
}
}, 999 );
Notes
To find a node ID, inspect the admin bar item: its list element id is "wp-admin-bar-" followed by the node ID.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.