You maybe already heard about the nofollow tag, invented by Google to prevent spam. In fact, it doesn’t prevent or decrease spam at all, and a lot of criticism has been expressed against it. Some of the reasons why you shouldn’t use nofollow are summed up at NoNoFollow, and a recent post about Google’s mistake is available here. Below, I’ll explain how to simply remove the nofollow tag from WordPress, without the need to install a plugin.
All you need to do is edit three files, wp-includes/default-filters.php, wp-includes/functions-formatting.php and wp-includes/comment-functions.php. In default-filters.php, a filter is set which adds the nofollow tag to links in comments. You need to change the following line (around line 28):
add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
Comment it out, so it becomes:
//add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
In functions-formatting.php, the make_clickable() function searches for links in comments to make them clickable, but not followable by search engines. Search the following (normally from line 572 to 579):
function make_clickable($ret) {
$ret = ' ' . $ret . ' ';
$ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i",
> "$1<a href='$2://$3' rel='nofollow'>$2://$3</a>", $ret);
$ret = preg_replace("#(\s)www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^ <>{}()\n\r]*[^., <>{}()\n\r]?)?)#i",
> "$1<a href='http://www.$2.$3$4' rel='nofollow'>www.$2.$3$4</a>", $ret);
$ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([a-z0-9\-_.]+)\.([^,< \n\r]+)#i",
> "$1<a href=\"mailto:$2@$3.$4\">$2@$3.$4</a>", $ret);
$ret = trim($ret);
return $ret;
}
And paste the following over it:
function make_clickable($ret) {
$ret = ' ' . $ret . ' ';
$ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i", "$1<a href='$2://$3'>$2://$3</a>", $ret);
$ret = preg_replace("#(\s)www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^ <>{}()\n\r]*[^., <>{}()\n\r]?)?)#i", "$1<a href='http://www.$2.$3$4'>www.$2.$3$4</a>", $ret);
$ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([a-z0-9\-_.]+)\.([^,< \n\r]+)#i", "$1<a href=\"mailto:$2@$3.$4\">$2@$3.$4</a>", $ret);
$ret = trim($ret);
return $ret;
}
The last change is in the file comment-functions.php, where the get_comment_author_link() function returns a link to the website of a commenter. Edit the following line (should be around line 378):
$return = "<a href='$url' rel='external nofollow'>$author</a>";
And change it to:
$return = "<a href='$url' rel='external'>$author</a>";
Feel free to comment on this post, links will be displayed and followed by search engines!







Comments on "How to disable nofollow in WordPress"
There's a total of 11 comments to this post. Add yours below.
1.
ptvGuy wrote:
On June 19th, 2006 at 9:54
2.
JW wrote:
On June 19th, 2006 at 16:37
3.
Standard Warfare wrote:
On October 16th, 2006 at 18:24
4.
Jan wrote:
On August 15th, 2007 at 13:15
5.
Anonymous wrote:
On October 24th, 2007 at 8:29
6.
jessie wrote:
On December 18th, 2007 at 20:34
7.
JW wrote:
On December 18th, 2007 at 22:30
8.
Tom wrote:
On April 11th, 2008 at 14:08
9.
Tom wrote:
On April 11th, 2008 at 14:10
The trackback URI of this post is http://jw.x10hosting.com/blog/2006/05/27/how-to-disable-nofollow-in-wordpress/trackback/
Mike's Blog => Say No To Nofollows! wrote:
On June 30th, 2006 at 23:27
This Blog Has DoFollow Attributes | What Have You wrote:
On December 18th, 2007 at 20:46