Is it easily possible to edit links in the WP_Admin_Bar
global $wp_admin_bar
instance?
Leave a Reply
You must be logged in to post a comment.
Is it easily possible to edit links in the WP_Admin_Bar
global $wp_admin_bar
instance?
You must be logged in to post a comment.
Yes I recently ran into the situation where I wanted to change the profile link in the user-info section of the admin bar. The problem is that you can only get all nodes, add and remove them. Not edit. And you also cannot modify the
$wp_admin_bar->nodes
property due it is private.When easily removing and adding them, you’ll lose your order and the whole thing looks horrible. Now here is my solution:
Ok, so I recently ran into an issue trying to create a custom Holiday/Time of Day Greeting for the WordPress Admin Toolbar and ran across this answer, which led me down a path of hours of wasted time since it is actually completely unnecessary. You don’t need to destroy and rebuild the admin toolbar to edit a node.
The simple solution for Julien’s issue is a 5 line addition to your functions.php file that replaces the desired url:
Now if you want to get a bit deeper into editing/manipulating the the Admin Toolbar – you can do something like this, which adds the website url of the user, if they entered one in their profile page, as a node to the Users Profile Panel (aka a link in the “sub-menu”):
Here is a screenshot of how that change looks in the “my-account” “user-actions” menu: