Getting Links in WordPress Comments to Open in a New Window

WordPress has gotten better over the years about seo and helping bloggers and site owners to build traffic, but it still has a couple of weaknesses.  One of the features that I am not fond of is how it opens links in comments in the same window.  If this bothers you too, here’s the solution…

First a hat tip to Adham who worked this out on a project we’re doing.

What you want to do is find the file wp-includes/formatting.php

and replace this line

return $matches[1] . “<a href=\”$url\” rel=\”nofollow\”>$url</a>” . $ret;

with

return $matches[1] . “<a href=\”$url\” rel=\”nofollow\” target=\”_blank\”>$url</a>” . $ret;

That’s it.  People can still click a link in the comment and go to that page, but now getting back to your fabulous content isn’t so difficult for them.

4 Responses to “Getting Links in WordPress Comments to Open in a New Window”

Leave a Reply