Remove WordPress' NoFollow Without A Plugin

Published: 2010-10-03

And even better, do so without modifying the WordPress core files. It's really quite simple.

In your templates functions.php file add

<?php function comment_author_link_mine( $comment_ID = 0 ) { echo get_comment_author_link_mine( $comment_ID ); } function get_comment_author_link_mine( $comment_ID = 0 ) { /** @todo Only call these functions when they are needed. Include in if... else blocks */ $url = get_comment_author_url( $comment_ID ); $author = get_comment_author( $comment_ID ); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "<a href='$url' class='comment_url'>$author</a>"; return apply_filters('get_comment_author_link', $return); } ?>

Then in your comments.php file, find and replace any mention of

<?php comment_author_link(); ?>

With

<?php comment_author_link_mine(); ?>

This simply replaces the core files "comment_author_link()" function with one of our own. The original has

$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";

as the link. We simply remove the rel attribute and change it to

$return = "<a href='$url' class='comment_url'>$author</a>";

and it removes the nofollow attribute from your comments. No modifying of the core files, and one less plugin to deal with.

If you have tips for removing other plugins and using your own solution, let me know in the comments.