WordPressLet’s face it every WordPress blog owner loves to see fresh new comments on their blog. They are a key part of your blog that makes it unique. Comments provide feedback, encourage discussions, and can help build new friendships and contacts.

If you have ever clicked on a commenter’s name, which is usually a link to another website you will see that you leave your website and go directly to theirs.

You are sending visitors away from your site and you have to wonder if they will return.

Would you rather make the commenter link open in a new window or tab? If so continue reading.

Screen shot example of the url link to open in a new window:

Wordpress Comment Link

 

Before deciding to do this let’s go over the pros and cons along with some additional information.

The pros:
When someone clicks on the name of a commenter they won’t leave your website. This can help reduce bounce rate, and it is also very likely that they will spend additional time on your site.

The cons:
If you reply to a comment as the administrator or enter your website into the URL field your link will also open in a new window or tab when clicked. This generally isn’t a big deal because the visitor is already on your website. If they do your website simply opens in a new window or tab too.

Additional Information:
You will need to edit a core WordPress file which means when there is a WordPress upgrade available it is possible that you would need to reapply this.

The good news is this is a very simple modification and only takes a few minutes of your time.

You should always download and backup the files you intend to modify or change. This will allow you to quickly restore the original in the event that you do something wrong.

 

How to open WordPress commenter URL link in a new window

 

Download and backup /wp-includes/comment-template.php to your local computer.

Open /wp-includes/comment-template.php from within your hosting account using an ftp client or your hosts online file editor.

Search and look for: (around line #225 WordPress 5.1.x)
$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";

Change to:
$return = "<a href='$url' rel='external nofollow' class='url' target='_blank'>$author</a>";

You are simply adding:
target=’_blank’

Note:
Those are single quotes (apostrophes) not double quotes.

Save the changes and test:

  • Save the changes back to your hosting account.
  • Refresh one of your posts that have comments with a commenter URL link.
  • Click on one of the commenter URL links and it should now open in a new window or tab.

Note about WordPress caching plugins:
If you have some form of a cache plugin installed and enabled you may need to clear or empty the cache. Then, refresh the page and test again.

To revert the changes back to the original settings:
Simply upload the backup file you downloaded earlier /wp-includes/comment-template.php to your hosting account overwriting the current file. Refresh the page and click on a comment URL link to verify. Clear or empty any WordPress cache plugin if necessary.

Alternatively open /wp-includes/comment-template.php from within your hosting account and remove target=’_blank’ and save the changes back to your host.

WordPress upgrade reminder:
Should there be a WordPress upgrade in the future that includes changes to /wp-includes/comment-template.php you will need to reapply this, as the upgrade will overwrite your changes.

This only takes a few moments and will only need to be reapplied if a WordPress upgrade includes changes to this file.

Additional WordPress information:
At the time of this post the current version of WordPress is 5.1.0

For WordPress versions prior to 5.1.x or after the process will likely be similar or identical unless WordPress decides to make major changes to the core code.

Making changes within WordPress administration using the theme editor:
If you have a custom theme / template there is a slight possibility that you can modify or edit one of your template files such as comments.php, functions.php or a custom-function.php directly within WordPress administration theme editor.

There is no way to guarantee this because it would be impossible to check all the different WordPress framework and themes out there, but there is a possibility.

For instance if you had something in your theme comments.php like:
<a href="<?php comment_author_url(); ?>">

You might change it to:
<a href="<?php comment_author_url(); ?>" target="_blank">

A better solution would be to manually edit and change /wp-includes/comment-template.php as explained above for universal compatibility.

Final Note:
Modify WordPress files at your own risk and be sure to download a backup before making any changes.

Download and install a plugin:
Or, you can download a plugin I created that is available in the WordPress Repository here:
Comment Links New Tab WordPress Plugin

Comment Links New Tab

About: Jeremy LeSarge - AKA: Ray (224 Posts)

I am the site owner and administrator of DialMe.com. I provide help and tips for Boonex Dolphin on the main part of this website where you will also find an assortment of other resources. Here, on the blog I write about a variety of topics surrounding WordPress, technology, social media/networking, SEO, and webmaster resources.