Adding a menu item to the top right of the admin bar


I know how to add items to the admin bar. Also with the priority setting you can define the position within the left of items. But I struggle to add something to the right section of the admin bar, right before the “Welcome..” link.

enter image description here

function add_item($admin_bar)  {
$args = array(
    'id'        => 'your-link', // Must be a unique name
    'title'     => 'Yoursite', // Label for this item
    'href'      =>__ ('your_site_url'),
    'meta'  => array(
        'target'=> '_blank', // Opens the link with a new tab
        'title' => __('Yoursite'), // Text will be shown on hovering
$admin_bar->add_menu( $args);
add_action('admin_bar_menu', 'add_item', 20000); // 20000 = High priority -> right

Even adding PHP_INT_MAX as the priority does not move my item any further to the right of the admin bar.

Koolio King 3 years 2020-06-05T03:10:31-05:00 0 Answers 97 views 0

Leave an answer