Support » Requests and Feedback » open in new tab when click on visit site

  • Hi,
    Please make it possible that when we click on visit site in dashboard, It would open in a new tab.
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    Right click and select “open link in new tab”. Changing the default behavior would affect millions of websites.

    Right click on visit site select, open in new tab. Your site will open in a new tab.

    It’s more convenient to have the Visit Site link open in a separate window.

    I used a plugin to do it until today, “Visit Site In New Tab”

    Did a google for a better way to do it without a plugin.

    Just found this code,
    Put it in your functions.php, if you have a child theme even better.
    Put your functions.php in the child theme.

    Add this code to the bottom of your functions.php

    add_action( 'admin_bar_menu', 'shatel_view', 999 );
    function shatel_view( $wp_admin_bar ) {
        $all_toolbar_nodes = $wp_admin_bar->get_nodes();
        foreach ( $all_toolbar_nodes as $node ) {
            if($node->id == 'site-name' || $node->id == 'view-site')
            {
            $args = $node;
                $args->meta = array('target' => '_blank');
            $wp_admin_bar->add_node( $args );
            }
        }
    }

    And finally delete plugin 🙂

    • This reply was modified 5 months, 3 weeks ago by sounds.
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.