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()
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityWhenever 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()
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 );
}
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);