0

Not sure where the function is that does this but i need to remove it so all links in comments do not contain the rel="nofollow" attribute.

I know i can use the comment_text filter to remove nofollow but thats not what i need to do.

What i need to do is remove the function from WordPress core which then enables me to manually add nofollow to comment links selectively.

2

Add this to your plugin file/theme's functions.php:

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

You could then add your own filter to pre_comment_content to use wp_rel_nofollow selectively, based on your criteria.

URLs that are automatically made clickable from plain-text urls like example.com aren't filterable in a way that allows removing of the rel="nofollow" attribute. The only solution for those is filtering comment_text or removing the auto-adding of links entirely:

remove_filter( 'comment_text', 'make_clickable', 9 );
  • Thanks Jacob however i just want to add nofollow to specific links in comments manually. – Dev Aug 4 '17 at 12:10
  • My answer will do what you're asking for in terms if turning off the automatic adding of nofollow, but in terms of adding them you'd just have to edit the comments. I'm not sure how else you'd expect to be able to do that or how that isn't already what you want. – Jacob Peattie Aug 4 '17 at 12:14
  • Only works when adding HTML links with a tags like this <a href="example.com">Link</a> but doesn't remove nofollow when adding text links like this example.com – Dev Aug 4 '17 at 13:00
  • Doesn't appear to be possible to remove it from those without filtering comment_text. I've updated my answer accordingly. – Jacob Peattie Aug 4 '17 at 13:11
  • 1
    Thanks. Worked for me with WordPress 4.8.1. Not sure why @Dev hasn't accepted your answer. – Karl Aug 29 '17 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.