I’ve recently added comments back into my blog. I know that Askimet will do the majority of the work in protecting me from SPAM, but I wanted to make sure I no-follow all the links too. I was interested to find out that WordPress nofollows all links in comments already.
This might not be preferred behaviour if you have internal links in your comments that you want to preserve, or if you want to have “authorised” users that can have the nofollow tag removed for any of their comments.
All you need to do is add the following links to your functions.php file.
1 2 3 4 5 |
function commentdofollow($text){ $return = str_replace('" rel="nofollow">', '">', $text); return $return; } add_filter('comment_text', 'commentdofollow'); |
Image Credit: Ali Catterall
Comment or tweet @douglasradburn