Are you looking for a way to links to WordPress 3.3 toolbar? Though, WordPress 3.3 is an old version and we highly recommend you to keep your website up-to-date. But, we have created a quick code snippet that you can use to add links to WordPress 3.3 toolbar.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
add_action('admin_bar_menu', 'add_toolbar_items', 100);
function add_toolbar_items($admin_bar){
$admin_bar->add_menu( array(
'id' => 'my-item',
'title' => 'My Item',
'href' => '#',
'meta' => array(
'title' => __('My Item'),
),
));
$admin_bar->add_menu( array(
'id' => 'my-sub-item',
'parent' => 'my-item',
'title' => 'My Sub Menu Item',
'href' => '#',
'meta' => array(
'title' => __('My Sub Menu Item'),
'target' => '_blank',
'class' => 'my_menu_item_class'
),
));
$admin_bar->add_menu( array(
'id' => 'my-second-sub-item',
'parent' => 'my-item',
'title' => 'My Second Sub Menu Item',
'href' => '#',
'meta' => array(
'title' => __('My Second Sub Menu Item'),
'target' => '_blank',
'class' => 'my_menu_item_class'
),
));
}
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 9 best constant contact alternatives to grow your list and why you need to build an email list now.
Comments Leave a Reply