WordPress comments links open in new window

commentslinksnewwindowWe would like links in any comments open in new window instead of same window because we still want to read more in that page. WordPress comments links open in same window as default action, adding following code snippet could make these links open in new window instead, just add the code into functions.php of your WordPress theme. That’s it.


function comment_links_in_new_tab($text) {
$return = str_replace('<a', '<a target="_blank"', $text);
return $return;
}
add_filter('get_comment_author_link', 'comment_links_in_new_tab');
add_filter('comment_text', 'comment_links_in_new_tab');


Comments

One response to “WordPress comments links open in new window”

  1. Just the information I was looking for.
    Thank you very much.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: