Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// remove WordPress items from toolbar
function preload_my_toolbar() {
global $wp_admin_bar;
// remove WordPress logo
$wp_admin_bar->remove_node('wp-logo');
// remove search button
$wp_admin_bar->remove_node('search');
}
// add custom items to toolbar
function my_toolbar() {
global $wp_admin_bar;
// add a single link
$wp_admin_bar->add_node( array(
'id' => 'my-link-one',
'title' => 'Item 1',
'href' => site_url()
) );
// add a item to the right of the menu using parent: top-secondary
$wp_admin_bar->add_node( array(
'id' => 'my-search',
'title' => 'Search',
'href' => '#',
'parent' => 'top-secondary'
) );
// add a sub-item
$wp_admin_bar->add_node( array(
'id' => 'my-google-search',
'title' => 'Google',
'parent' => 'my-search',
'href' => 'http://www.google.com',
'meta' =>array( 'target' => '_blank' )
) );
// add another sub-item
$wp_admin_bar->add_node( array(
'id' => 'my-bing-search',
'title' => 'Bing',
'parent' => 'my-search',
'href' => 'http://www.bing.com',
'meta' =>array( 'target' => '_blank' )
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.