How can you remove spam links from your WordPress comments text? If you get thousands of spam comments everyday, even with anti-spam comment tools, Â there is a chance that many spam comments were able to get posted and had malicious links to spam websites. Editing thousands of comments is a tedious task.
As link removal requests get more common due to multiple Google penalties and webmasters find bad links pointing from your site, there is a high chance they will request link removal or add your site to the disavow tool.
I always wanted a way to bulk remove such links from all my WordPress comments … and I just did this with a single line of code.
WordPress Makes LinksÂ Clickable
For example, lets see this link posted in a comment. [Please note this particular comment is shown as an example only and the comment link is not spam]
If you actually see the comment in the Edit screen, there was no clickable complete url.
In fact it is a cool feature ofÂ WordPress that makes aÂ text link clickableÂ in this comment.
Removing Comment Links
So here is what I did. I added this single line of code to the theme functions.php file. [Be careful when you edit this important file in your themes editor, as wrong edits can take your blog offline – keep a backup and restore via FTP if needed]
remove_filter('comment_text', 'make_clickable', 9);
This disables the ability of WordPress to makes all these links clickable in the comments text. And now when you see the same comments after using this code, you see the clickable links are gone!
NOTE: This will affect remove ALL links (spam and not spam) in comments text only (not comment author links) Â on your whole blog. The links will become non clickable, but would stay as text links. This would mean effectively thousands of published spam links will disappear instantly! Try it.