How to change the Admin-bar’s link target?

I’d like to change the admin bar’s link target to “_blank”.
where what should I do?
thanks.

1 Answer
1

function remove_admin_bar_links() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('site-name');
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

function my_admin_bar_menu() {
    global $wp_admin_bar;
    if ( !is_super_admin() || !is_admin_bar_showing() )
        return;
    $wp_admin_bar->add_menu( array(
    'id' => 'site-name',
    'title' => get_bloginfo('name'),
    'href' => get_bloginfo('home_url'),
    'meta' => array('target' => '_blank' ) );
}
add_action('admin_bar_menu', 'my_admin_bar_menu');

There is actually a lot more you can do. But this should get your started in the right direction.

Sources:
https://wordpress.stackexchange.com/questions/11522/just-wanted-to-share-about-the-admin-bar
http://wpengineer.com/2113/add-menus-to-the-admin-bar-of-wordpress/

Leave a Comment