WP_Admin_Bar::remove_node( string $id )

Remove a node.



(string) (Required) The ID of the item.

Top ↑

More Information

This function removes an item from the Toolbar. Toolbar items are also called “nodes”.

Top ↑

Finding Toolbar Node ID’s

The node ID’s can be found in the HTML source code of any WordPress page with a Toolbar on it. Find the list items that have ID’s that start with “wp-admin-bar-“. For example, the list item ID for the WordPress Logo on the left in the Toolbar is “wp-admin-bar-wp-logo”:

<li id="wp-admin-bar-wp-logo" class="menupop"> … </li>

Remove “wp-admin-bar-” from the list item ID to get the node ID. From this example the node ID is “wp-logo”.

Note: It’s also possible to see all node ID’s with the example from get_nodes().

Top ↑


File: wp-includes/class-wp-admin-bar.php

	public function remove_node( $id ) {
		$this->_unset_node( $id );

Top ↑


Version Description
3.1.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content

    The following code removes the Customizer links, Background and Header from the Toolbar drop-downs:

     * Remove Customize menus from the Toolbar.
     * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
    function wpdocs_remove_customize( $wp_admin_bar ) {
    	// Remove customize, background and header from the menu bar.	
    	$wp_admin_bar->remove_node( 'customize' );  
    	$wp_admin_bar->remove_node( 'customize-background' );   
    	$wp_admin_bar->remove_node( 'customize-header' );   
    add_action( 'admin_bar_menu', 'wpdocs_remove_customize', 999 );

    The following code removes the WP logo and the Comments menu:

     * Remove WP logo and comments from the Toolbar.
     * @param WP_Admin_Bar $wp_admin_bar WP_Admin Bar instance.
    function wpdocs_remove_logo_comments( $wp_admin_bar ) {
    	// Remove wp-logo and comments from the menu bar.
    	$wp_admin_bar->remove_node( 'wp-logo' );  
    	$wp_admin_bar->remove_node( 'comments' );    
    add_action( 'admin_bar_menu', 'wpdocs_remove_logo_comments', 999 );

You must log in before being able to contribute a note or feedback.