I would like to add a new menu item in the admin bar. So far, I have done the following:
function add_book_menu_item ($wp_admin_bar) {
$args = array (
'id' => 'book',
'title' => 'Book',
'href' => 'http://example.com/',
'parent' => 'new-content'
);
$wp_admin_bar->add_node( $args );
}
add_action('admin_bar_menu', 'add_book_menu_item');
This is creating the Book
menu item underneath the + New
menu (in the admin toolbar). However, the Book
item comes in first (it is before the Post
menu item). I would like it to appear between the Media
and Page
items.
The following image shows what I would like to do.
How do I do that?
Thanks.
2 Answers
every menu have an number . lower the number priority.
add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );
add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
more clear idea you can check the link below