Stop nofollow rel being added to Wordpress links

I recently had a client come to me, requesting a fix for the rel="nofollow" that is automatically added to Wordpress comment links.

It appears to be a protection against spam comments, or people trying to get a 'cheap' backlink on a high DA site, but seems to wind a lot of people up! The problem is, when you google the fix, you get this code suggested:

remove_filter( ‘pre_comment_content’, ‘wp_rel_nofollow’, 15 );

However, this doesn't always work. Wordpress has a second, sneaky filter tucked away, which adds 'ugc' to the rel attribute. This filter ALSO adds nofollow. So if the above code isn't working, try this one:

remove_filter( 'pre_comment_content', 'wp_rel_ugc', 15 );

This won't remove nofollow from any existing comments you have in Wordpress, but it will stop it being forced on all comments moving forward (edited or new).  If you need to remove it from existing comments also, you can string replace like this:

//Remove nofollow from existing comments
function remove_nofollow($string) {
$string = str_ireplace('nofollow', '', $string);
return $string;
add_filter('comment_text', 'remove_nofollow');

All of these can be added to the functions.php file of your child theme!

Russ Clow

Freelance Website Designer & Developer


I've been designing and developing websites for a very long time. In that time, I've learnt many things - and this article is written to help share that knowledge with others. Everything within this article is written based on my experience, but is my own professional view.

If you would like to tap into my knowledge further, please contact me for a free, no obligation quote.

Need a quote?  Contact me