Search result links open in a new window

When clicking on a search result link, it opens in a new window.

How do I maintain so it opens in the same window?
I know it is possible, as I used another plugin that maintained the links in the same window.



  • Alexander

    Hi @darko85,

    The HTML is entirely generated by Google, so there isn't a setting for this. However, one workaround would be to remove the ' target="_blank" ' attribute from all the links after the page loads. This can easily be done with jQuery

    Here's the code that will do this for you. This is JavaScript, and will need to be added to your theme, or within a plugin.


    If you want to give it a quick test, just pull up your page and copy and paste that line into the javascript console in your browser. (On Chrome it's under View -> Developer -> Javascript Console)

  • Alexander


    As it is actually more of a hack that goes back to alter data after google renders it, I suspect it won't be included with the plugin.

    I'm sorry, this is actually JavaScript, so it can't be include in functions.php. Rather you would need to include it in a javascript file. Or, you could include it in your functions.php by hooking into the Wordpress footer. Here's the code that will do this for you:

    function custom_google_remove_target(){ ?>
    <?php } 
    add_action('wp_footer', 'custom_google_remove_target'); ?>

    Hope this helps!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.