WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get node

Description

This function returns a Toolbar object with all the properties of a single Toolbar item. Toolbar items are also called "nodes".

The Toolbar replaces the Admin Bar since WordPress Version 3.3.

note: This function is a method of the WP_Admin_Bar class and $wp_admin_bar global object, which may not exist except during the 'admin_bar_menu' or 'wp_before_admin_bar_render' hooks.

Usage

<?php $wp_admin_bar->get_node$id ); ?>

Parameters

$id
(string) (required) The node ID of the Toolbar item you want to get.
Default: None

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 this example from get_nodes().

Examples

Remove the Toolbar "Updates" Item if it Exists

Put this in your theme's functions.php file.

add_action( 'admin_bar_menu', 'check_updates_node', 999 );

function check_updates_node( $wp_admin_bar ) {

	$updates_node = $wp_admin_bar->get_node( 'updates' );

	// Check if the 'updates' node exists
	if( $updates_node ) {
		$wp_admin_bar->remove_node( 'updates' );
	}
}

Return Values

  • Object when the node is found.

Change Log

Source File

get_node() is located in wp-includes/class-wp-admin-bar.php.

Related

Toolbar API

See also index of Function Reference and index of Template Tags.
This article is marked as in need of editing. You can help Codex by editing it.