WordPress add new menu in admin bar settings

In WordPress top admin bar add new our custom menu to add this script in functions.php file to set in top of the admin bar.

Step => 1 Add this script in your theme functions.php file.
function MyCustomAdmin_menu() {
    global $wp_admin_bar;
    if ( !is_super_admin() || !is_admin_bar_showing() )
        return;
               
    $wp_admin_bar->add_menu( array(
    'id' => 'custom_menu_theme',
    'title' => __( 'Themes', 'theme-slug' ),
    'href' =>  admin_url('themes.php'),
    'meta' => array('target' => 'blank', 'title' => 'Go to theme page', 'class' => 'themepage') ) );
   
    $wp_admin_bar->add_menu( array(
    'id' => 'dalwadiwp',
    'parent' => 'custom_menu_theme',
    'title' => __( 'Dalwadiwp', 'theme-slug' ),
    'href' => 'https://dalwadiwp.wordpress.com',
    'meta' => array('target' => 'blank', 'title' => 'Learn more about dalwadiwp') ) );
   
    $wp_admin_bar->add_menu( array(
    'id' => 'dalwadiwp_1',
    'parent' => 'dalwadiwp',
    'title' => __( 'My Custom Menu', 'theme-slug' ),
    'href' => 'https://dalwadiwp.wordpress.com',
    'meta' => array('target' => 'blank', 'title' => 'Learn more about dalwadiwp')
        ) );
}
add_action('admin_bar_menu', 'MyCustomAdmin_menu', 99);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s