WP_Admin_Bar::get_node() WordPress Method

The WP_Admin_Bar::get_node() method is used to get a specific node from the admin bar. The node is identified by its id.

WP_Admin_Bar::get_node( string $id ) #

Gets a node.


Parameters

$id

(string)(Required)


Top ↑

Return

(object|void) Node.


Top ↑

More Information

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

The parameter $id is the node ID of the Toolbar item you want to get. Default is None.

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


Top ↑

Source

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

	final public function get_node( $id ) {
		$node = $this->_get_node( $id );
		if ( $node ) {
			return clone $node;
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.