Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Add a Page to The Toolbar in WordPress

How to Add a Page to the Toolbar in WordPress

If you are a WordPress plugin developer OR WordPress theme developer and want to add your custom pages or custom links in your admin toolbar menu, then keep your close attention in this tutorial as I am going to share how to add a page to the toolbar in WordPress.

How to Add a Page to the Toolbar in WordPress

Copy the below code and paste it at the end of the functions.php file.

 'search_freewebmentor',
        'title' => 'Search FreeWebMentor',
        'href'  => admin_url( 'admin.php?page=mb_email_configuration' ),
        'meta'  => array( 'class' => 'my-toolbar-page' )
    );

    $wp_admin_bar->add_node( $args );
}

add_action( 'admin_bar_menu', 'toolbar_link_to_mypage', 999 );

?>

Single function to add parent/child sub menu items

Copy below code and paste it into your functions.php file if you want to add parent/child sub menu in Admin toolbar in Wordpress

function social_media_links($wp_admin_bar)
{

    $args = array(
        'id'     => 'search_freewebmentor',
        'title' =>  'Search FreeWebMentor',
        'meta'   => array( 'class' => 'first-toolbar-group' ),
    );
    $wp_admin_bar->add_node( $args );   

    // add child items
    $args = array();
    array_push($args,array(
        'id'        =>  'twitter',
        'title'     =>  'Twitter',
        'href'      =>  'http://www.twitter.com',
        'parent'    =>  'social_media',
    ));

    array_push($args,array(
        'id'        => 'youtube',
        'title'     =>  'YouTube',
        'href'      =>  'http://www.YouTube.com',
        'parent'    => 'social_media',
        'meta'      => array( 'class' => 'first-toolbar-group' ),
    ));
    array_push($args,array(
        'id'        =>  'fb',
        'title'     =>  'Facebook',
        'href'      =>  'http://www.facebook.com',
        'parent'    =>  'social_media',
    ));

    sort($args);
    foreach( $args as $each_arg)    {
        $wp_admin_bar->add_node($each_arg);
    }

} 

add_action( 'admin_bar_menu', 'social_media_links', 900 );

After adding the above in your functions.php file new toolbar will be added in your WordPress admin.

How to Add a Page to the Toolbar in WordPress

Conclusion

I hope this tutorial helps you, if you have any questions regarding WordPress, then feel free to put your comments in below comment section. Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.

The post How to Add a Page to The Toolbar in WordPress appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

How to Add a Page to The Toolbar in WordPress

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×