Paste the code below into your functions.php file.
// add a link to the WP Toolbar
function custom_toolbar_link($wp_admin_bar) {
$args = array(
'id' => 'gmail',
'title' => 'Gmail',
'href' => 'https://mail.google.com/mail/#inbox',
'meta' => array(
'class' => 'gmail',
'title' => '[email protected]'
)
);
$wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'custom_toolbar_link', 999);
Once done, edit the following, then save the file. You’re done!
‘id’ => ‘gmail’ — the ID of the
‘title’ => ‘Gmail’ — the anchor-text for the custom link
‘href’ => ‘https://mail.google.com/mail/#inbox’ — the URL for the custom link
‘class’ => ‘gmail’ — the class attribute for the custom link
‘title’ => ‘[email protected]’ — the title attribute for the custom link
Thanks to Jeff Starr for the cool tip!