Disabling old wordpress comments

As with most individuals that manage a blog, I get inundated with comment spam. Based on some research I did, it looks like almost all of the blog spam occurs for older posts, especially those over 30 days old. Based on this information, I decided to disable comments for all old posts older than 30 days. It turns out that you can’t do this directly from wordpress without a plugin, so I decided to adjust the “comment_status” column in the wp_posts table directly. To remove comment spam for all posts older than 30 days, I first used the GNU date utility to find the date 30 days ago:

$ date –date=”30 days ago” “+%Y-%m-%d”

Once I had the date string from 30 days ago, I connected to the MySQL database that hosts my blog, and ran the following SQL query to disable posts for all entries greater than the date returned form GNU date:

$ mysql -umatty -p -h mysql.prefetch.net
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16155903 to server version: 4.0.27-standard-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use matty
Database changed

mysql> UPDATE wp_posts SET comment_status = ‘closed’ WHERE post_date < '2006-11-29' AND post_status = 'publish'

mysql> quit

Now that old posts don’t have comments enabled, I am curious to see how the comment spammers react.

6 thoughts on “Disabling old wordpress comments”

  1. I used to use spam karma, but switched to akismet since it consumes fewer resources. Akismet catches nearly all comment spam, but I don’t like the fact that spammers are chewing up resources on my web server! Now if only there was a wordpress plugin that added ipfilter rules on the fly. :)

    – Ryan

  2. Are you sure you set it to 30 days? It looks like your posts as recent as 24 December (not even two weeks ago) no longer accept comments.

    The best strategy for deflecting comment spam on older entries that I’ve seen is found in the Serendipity blog engine (http://s9y.org/). By default it requires the vistor to enter a captcha to comment on older entries. It’s much more user-friendly than disabling comments altogether.

  3. I have been playing with different dates as part of my research into blog spam, and closed out all comments that were older than 7-days to test a theory.

  4. But why one should disable older valid comments? What i think is number of comments gives idea about popularity of post. Isn’t it?

    But spamming is on peak. Within 2 months of applying of akismet I have registered a considerable number of spams. It rose to 4,XXX from 1,XXX. While the blog was up for past 10 months.

Leave a Reply

Your email address will not be published. Required fields are marked *