How to add no follow rel for comments in wordpress ?

9. January 2010

You need to look at my code and edit your code accordingly, before that please read post carefully and create a backup of file functions.php

1.Open the functions.php file in ur current theme and put these code within php tags.

What it will do:
1. Will add ‘no follow’ as rel in url , if comment contains any url.
2. Will ad ‘external’ as rel in url , if comment contains any url.
3. Will add target=”_blank” in comment author’s url so that their web url open’s in new window/new tab as in browser settings
4. Will add target=”_blank” to url, if comment contains any url
5. Wp adds ‘no follow’, ‘external’ rel in comment author’s url by default. So we don’t need to add this :P

Code:

  function nofollow($text) {
$text = preg_replace('/<a /i','<a rel="nofollow external" ',$text);
$text = preg_replace('/<a /i','<a target="_blank" ',$text);
return $text;
}
function targetblank($text){
$text = preg_replace('/<a /i','<a target="_blank" ',$text);
return $text;
}

add_filter('comment_text', 'nofollow');
add_filter('get_comment_author_link','targetblank');

 

Good Luck !

 

Tips n Tricks

Comments

3/6/2010 9:49:58 AM #
I have never seen such a great blog and allposts seem to be original.
5/5/2010 9:51:13 AM #
Pingback from endyear2012.com

car insurance cheap quote «  End Year 2012
6/5/2010 5:09:11 AM #
This is a very exciting post, I was looking for this knowledge. Just so you know I found your web site when I was doing research for blogs like mine, so please check out my site sometime and leave me a comment to let me know what you think.
7/16/2010 7:50:51 AM #
Excellent site, keep up the good work. I read a lot of blogs on a daily basis and for the most  part, people lack substance but, I just wanted to make a quick comment to say I’m glad I found your blog. Thanks,
7/19/2010 2:37:13 AM #
sagabindara salutes you all out there
7/21/2010 8:45:54 AM #
The fact that your blog entry here just uncovered some of the coolest new knowledge and online social trends in one go. How frickin' cool is that!
8/2/2010 1:39:11 PM #
no doubt this post realy got something in it ...!!
Jona Deets
Jona Deets
8/3/2010 10:25:14 AM #
I used to be wondering if you would like to be a visitor poster on my blog? and in alternate you could possibly put one link the put up? Please reply whenever you get an opportunity and I will ship you my contact particulars - thanks
8/16/2010 4:07:36 PM #
I am blown away at how wonderful the content is on this web page. I have written down this page and I really  intend on coming back to the site in the next few days. Great job keep up the great work!
8/30/2010 4:34:02 AM #
Pingback from robfortner82.wordpress.com

Help File: Ways to recover a hacked Gmail, Hotmail or Yahoo Mail account  « Rob Fortner's Blog

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading