WP_Admin_Bar::remove_node() WordPress Method
The WP_Admin_Bar::remove_node() method can be used to programmatically remove a node from the admin bar. The method takes two parameters: the id of the node to be removed, and an optional boolean value specifying whether to also remove all child nodes of the specified node.
WP_Admin_Bar::remove_node( string $id ) #
Remove a node.
Parameters
- $id
(string)(Required)The ID of the item.
More Information
This function removes an item from the Toolbar. Toolbar items are also called “nodes”.
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().
Source
File: wp-includes/class-wp-admin-bar.php
public function remove_node( $id ) { $this->_unset_node( $id ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |