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?
To replace nofollow with nofollow external _blank
nofollow
nofollow external _blank
Put this code in your theme's functions.php file to replace text as required.
functions.php
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
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the privacy policy and terms of service.
tagged
asked
9 months ago
viewed
31 times
active