Whenever a user presses on a comments author it redirects the user to the site which was enetered by user. I just want to add the target="_blank" element. where I can modify this?

In file i see only this: get_comment_author_link()

2 Answers 2


You would have to use the get_comment_author_link filter for this in the following manner.

add_filter( "get_comment_author_link", "wpse_63316_modifiy_comment_author_anchor" );
function wpse_63316_modifiy_comment_author_anchor( $author_link ){
    return str_replace( "<a", "<a target='_blank'", $author_link );
  • Just tested this solution and longer works.
    – Dev
    May 19, 2017 at 12:09

Add an custom class to comment_author_link. When using 'get_comment_author_link' this function to fetch comment author link.

Just add this code into functions.php

// filter for get_comment_author_link
function custom_get_comment_author_link($content)
    $extra_classes = 'text-decoration-none text-primary fw-bold mb-0';
    return preg_replace('/url/', 'url ' . $extra_classes, $content);

add_filter('get_comment_author_link', 'custom_get_comment_author_link', 99);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.