Skip to content

spam

Fighting AI-generated comment spam on WordPress

Recently, I’ve been getting a new type of comment spam on my blog.

The comments are surprisingly relevant to the articles they’re posted on. They refer to the actual content of the blog post, use appropriate terminology and even sound as though someone has taken the time to read what I wrote.

Except they have that familiar, bland, generic style of AI-generated text. They say something vaguely positive about the article, perhaps add a superficial observation, and then include a link.

The link is the whole point.

I suspect these comments are generated by large language models (LLMs). Rather than posting the same generic spam message everywhere, spammers can now generate a superficially relevant comment for each individual blog post. That makes the comments harder to distinguish from genuine contributions using simple content filters.

I don’t particularly mind whether someone uses AI to help write a comment. What bothers me is using AI to manufacture plausible-looking comments solely to smuggle promotional links onto other people’s websites.

So I decided to address the actual problem rather than trying to determine whether a comment was written by a human or an AI.

No URLs in comments

My solution is straightforward: comments on my blog are no longer allowed to contain URLs.

I use the Code Snippets plugin to add a few small PHP snippets to WordPress.

The first removes the Website field from the comment form. The second rejects comments containing URLs. Another one prevents comment authors’ names from linking to their websites, including when older comments already have a URL stored in WordPress. And finally, comments are disabled on any post older than 180 days.

This doesn’t stop bots from submitting AI-generated comments. They can still generate text that refers to the article, praise the author and imitate the style of a genuine discussion.

But they can’t use the comment to publish their spammy links.

That’s the distinction I care about. I don’t need to identify every spammer or build a perfect AI detector. I just need to remove the incentive for this particular kind of spam.

If someone genuinely wants to contribute to a discussion, they can still do so. They simply can’t use my comment section as a vehicle for link promotion.

A small, pragmatic solution

This isn’t a universal solution to comment spam. Spammers can adapt, and not every unwanted comment contains a URL. The URL detection is also based on pattern matching, so it isn’t foolproof.

But it addresses the behaviour I’m actually seeing, without adding another dedicated plugin or trying to outsmart the latest AI-generated text.

If the bots want to keep writing bland, AI-generated comments about my blog posts, they’re welcome to try.

They just won’t get to leave their links.

The actual PHP code is left as an exercise to the reader.