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');

Summary
Article Name
WordPress comments links open in new window
Description
How to make comments links open in new window
Author
  • 김종수

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