0

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?

  • 1
    please post your wp_list_comments() section and what have you tried so far. – pcarvalho Aug 3 '12 at 6:22
1

To replace nofollow with nofollow 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

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.