Is it possible to create a filter to make in sort that the link in the admin bar to open in a new window. I know that the right-click -> open in a new tab is a common use for us programmers but for the client who use it, it could be great to open in a new tab.

enter image description here

Hope to find a solution without changing the core file "admin-bar.php" so it won't get overwrite on any WP's updates.


This is actually easily done. I just adapted the code from this answer

add_action( 'admin_bar_menu', 'customize_my_wp_admin_bar', 80 );
function customize_my_wp_admin_bar( $wp_admin_bar ) {

    //Get a reference to the view-site node to modify.
    $node = $wp_admin_bar->get_node('view-site');

    //Change target
    $node->meta['target'] = '_blank';

    //Update Node.


To change any other item in the menu bar you just need to find the id of the item to change and adapt get_node. Look in /wp-includes/admin-bar.php for the id or have a look at the css classes of the output.

  • Nice it works. Just like that, is it possible to add this action on the parent. The one with the little house icon ? – Warface Jun 6 '14 at 14:40
  • 1
    Have a look at the edited answer. You are looking for id site-name in wp-includes/admin-bar.php:285 – kraftner Jun 6 '14 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.