How to Add a menu, with sub-menu, that contains multiple links, that all open in a new window

Shortlink:

Add a menu, with sub-menu, that contains multiple links, that all open in a new window
/*
* Add a menu, with sub-menu, that contains multiple links, that all open in a new
window
* Change the Menu ‘title’ name and ‘href’ link.
*/

function custom_adminbar_menu( $meta = TRUE ) {
global $wp_admin_bar;
if ( !is_user_logged_in() ) { return; }
if ( !is_super_admin() || !is_admin_bar_showing() ) { return; }
$wp_admin_bar->add_menu( array(
'id' => 'custom_menu',
'title' => __( 'Menu Name' ) ) /* set the menu name */
);
/* sub-menu */
$wp_admin_bar->add_menu( array(
'parent' => 'custom_menu',
'id' => 'custom_links',
'title' => __( 'Sub menu') ) /* set the sub-menu
name */
);
/* menu links */
$wp_admin_bar->add_menu( array(
'parent' => 'custom_links',
'title' => 'Google', /* Set
the link title */
'href' => 'http://google.com/', /* Set the link
a href */
'meta' => array( target => '_blank' ) )
);
$wp_admin_bar->add_menu( array(
'parent' => 'custom_links',
'title' => 'Yahoo', /* Set
the link title */
'href' => 'http://yahoo.com/', /* Set the link a href
*/
'meta' => array( target => '_blank' ) )
);
}
add_action( 'admin_bar_menu', 'custom_adminbar_menu', 15 );

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!