Archive for July, 2009
Mass Delete Spam Comments from WordPress
I normally don’t (and won’t) post purely-techie articles like this, but the solution I found was so useful that I decided to share it.
The situation: I had an unmoderated “secret” blog whose address no one knew that I used as a theme sandbox, which in my foolish ignorance I did two things: I did not install Akismet on it, and I left Comments on and requirements low. I have had this blog up for…years now, on thinking about it…and in the time since I lasted cleaned out the comment queue I had acquired more than 44,000 comments from spam bots. Loading the Comments page took forever, and it resulted in more than 2,000 pages worth of comments waiting to be approved. There is no way to delete all comments within WordPress itself, and I did NOT want to sit through 2,000 pages worth of “Select All > Delete > Apply to All” and wait for the next page of dietary supplements, gambling franchises, and male enhancement aids to load. So I searched the web and found a solution.
This requires that you have phpAdmin, a standard practice amongst WordPress bloggers, though I imagine other MySQL database management webware will offer similar options. You must simply empty your “wp_comments” table on the database that holds your blogs’ data. In phpAdmin, this involves simply clicking the trashcan incon that says “Empty” when you hover over it; it should be relatively obvious that you have the right table since it will be flooded with records. It takes a matter of seconds.
Keep in mind, this will delete EVERY comment in your database. If you have comments you want to keep, this is not the solution for you. That said, it seems to be much easier to selectively delete records using the ‘Browse’ function in phpMyAdmin than to sit through the reloading of however many pages your comments take up in the WordPress Dashboard.
I had no comments that were ‘real,’ so I had no qualms about deleting them all; if you do, I suggest you limit your search for valid comments to a specific date range and delete all records up to that range without vetting them. Make a post apologizing if the comment got eaten, and move on. If you’re experiencing this problem, odds are you don’t have time to sift through all the comments for a solution.
You’re not done yet! Your records are beautifully empty, but now you must prevent this from happeneing again. This involves some combination of installing Akismet and turning off comments (or modifying — in some cases, severely — the permissions required to post a comment).
Good luck!
No comments