One of my senior brother just asked me, how to add no follow rel for comments in wordpress. May be there is plugin for this. Look to my code đ
How to use:
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 đ
Tips:
1.If possible upgrade to wp2.8.2
[code language=”php”]
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’);
[/code]
any question ask me đ
p.s.: post image is just for fun đ
BTW, are you afraid of editing your functions.php ? Ok, no problem you can add the above piece of code using the bellow wp plugin.
[download id=”9″]
Duh, you are totally unhappy with this post, na ? You can to treat your commentors with “cake and cook”, ok no problem.Just forget my post and read this blog post …“The Single, Most Profound Way To Thank Your Commenters”.
Happy now ?
hello,
it's good but not too much secure
becouse you use
<a
ok but if the use add
<A A Letter is cap
thank you
I want to make people lost!
thanks mate – I was looking for this article – worked like a charm!
Those preg_replaces are good only if the user hasn't inserted in comment the nofollow tag already.
Nofollow and dofollow are two important topic for page rank. If in ur website, dofollow links are kept, your page rank will be affected for that dofollow
thanks sabuj. my mistake. will definitely use it.
sabuj, excellent solution. will definitely use. should we use the plugin or functions.php hack? please advise.
Dear rayhan vai, I think u didn't read the post details. Please check there are two ways. You can direct edit ur functions.php file to add the codes or use as plugin that is given for download which will do same thing and u don't need to edit functions.php . thank you đ
thanks man… i’ve been looking for these..
āĻāĻ “āĻ¨ā§ āĻĢāĻ˛ā§” āĻāĻāĻāĻž āĻāĻŋ āĻāĻŋāĻ¨āĻŋāĻ¸ āĻāĻžāĻāĻāĻžāĻ¨?
āĻāĻžāĻ˛ā§ āĻšā§āĻ¯āĻžāĻ āĻŽāĻžāĻ¨āĻā§ āĻāĻžāĻ! āĻāĻžāĻā§ āĻ˛āĻžāĻāĻŦā§!
He He He
I want to make people lost!