Customizing Admin Toolbar to provide Extra Help

Here are two quick snippets of code to change the admin toolbar for your partners. I find them both useful – let’s discuss in class.

//Change Howdy Text
function change_howdy_text_toolbar($wp_admin_bar)
        $getgreetings = $wp_admin_bar->get_node('my-account');
        $newtitle = str_replace('Howdy','NEWGREETINGHERE',$getgreetings->title);
add_action( 'admin_bar_menu', 'Add_Menu_To_Toolbar', 500 );

function Add_Menu_To_Toolbar($wp_admin_bar){

$menu = wp_get_nav_menu_object( "Toolbar Menu" );
$menu_items = wp_get_nav_menu_items( $menu->term_id );

   foreach ($menu_items as $items) {
        $args = array( 'id' =>  $items->ID,
                'title' =>      $items->title,
                'parent' =>     $items->menu_item_parent,
                'href'  =>      $items->url,
                'meta'  =>      FALSE

        $wp_admin_bar->add_node( $args );

(note: you will of course have to CREATE A MENU in the Appearance --> Menu interface in the WordPress admin area.)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>