I want to add a link to my site in the admin bar, and make that link the leftmost item in the admin bar. I can add a link with this in a plugin function:
$wp_admin_bar->add_menu( array(
'id' => 'my-link',
'title' => __('MySite'),
'href' => site_url()
) );
But I’d like to make it the leftmost link in the admin bar, i.e. all the way in the top left corner. Is there a way to do this?
If I am correct these are the default positions:
small code snippet from what I use:
add_action('admin_bar_menu', 'your_function_name', 10);
The
10
should bring it to the most left side in the adminbar.At moment we are at WP version 3.8 and it still work like a charm.
Added example:
I attempted Charles solution but with no success. I did find out though that you can specify whether which side of the admin bar your content is added.
Using
will add your new content to the left side of the admin bar before the default content.
Using
will add your new content to the right side of the admin bar after the default content.
If you want to completely reorganize the admin bar you must use
WP_Admin_Bar()
.Example:
https://codex.wordpress.org/Class_Reference/WP_Admin_Bar