If you’re here, more than likely you are trying to fix an SEO issue identified on your WordPress website by an SEO Tool like SEMrush or ahrefs. During an audit of your site, they probably mentioned that you have “Nofollow attributes in outgoing internal links”.
Digging deeper, you may have realized that these “nofollow” links are coming from your comment reply links. You may even be frustrated to see that these links aren’t even visible on pages without comments, yet they are still triggering this alert.
Fortunately, it’s not too hard to solve!
You just need access to add a few lines of code to your child theme’s “functions.php” file. If you don’t know what that means, you are probably out of your depth at this point and should probably hire someone to help you.
As always: make sure you run a full-site backup to your site before modifying any code. Making code changes can be potentially dangerous to your site. Proceed at your own risk.
In order to remove "rel=nofollow" from your comment reply links, just add this code to your child theme’s functions.php file:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Functions to remove "rel=nofollow" from comment reply links - Credit PageCrafter - https://pagecrafter.com // Remove rel=nofollow from regular comment reply links function pc_remove_nofollow($link, $args, $comment, $post){ return str_replace("rel='nofollow' ", "", $link); } add_filter('comment_reply_link', 'pc_remove_nofollow', 100, 4); // Remove rel=nofollow from cancel comment reply links function pc_remove_nofollow_cancel_edit($formatted_link, $link, $text){ return str_replace('rel="nofollow"', "", $formatted_link ); } add_filter('cancel_comment_reply_link', 'pc_remove_nofollow_cancel_edit', 10, 3); |
This code actually removes the nofollow attribute in two places:
- The comment reply link
- A second link that appears once you start replying to a comment, which cancels your reply
Once you’ve implemented this code, you should no longer have any internal nofollow links owing to the comments.
Now, you may be wondering: does this matter? Is it actually important?
I don’t really have an answer for you. Probably not, to be honest. I think Google can tell these are issues, and there’s a reason WordPress opted to leave these in.
But if you enjoy bumping up the numbers for your site health and can’t stand to see these “warnings” remain, you might as well do it.
Good luck!