When a link is posted in a comment, the format is : rel="nofollow"
Using a function, how can I change that to : rel="external nofollow _blank"
So the links open in a new window?
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 communityWhen a link is posted in a comment, the format is : rel="nofollow"
Using a function, how can I change that to : rel="external nofollow _blank"
So the links open in a new window?
To replace
nofollow
withnofollow external _blank
Put this code in your theme's functions.php
file to replace text as required.
function wpse_60668_relnofollow($text) {
$return = str_replace('nofollow', 'external nofollow _blank', $text);
return $return;
}
add_filter('get_comment_author_link', 'wpse_60668_relnofollow'); //this'll change author link
add_filter('comment_text', 'wpse_60668_relnofollow'); //This'll change the content