How To Mass Delete Spam Comments In WordPress

WordPress
A buddy of mine left his WordPress blog unattended for several months because he wasn’t publishing new content at the time nor was he monitoring the comments. Unfortunately, his blog didn’t have a Disqus or Facebook comment system in place and he failed to include a spam filter such as Akismet with his current comment system. The result: thousands and thousands of spam comments flooded his blog posts.

At the time of this writing, WordPress doesn’t have a way for the user to send spam comments to the trash with a single click. I’m sure that feature will be added in the future, perhaps an “Empty Spam” button similar to the “Empty Trash” button, but for now the user must either manually select each spam comment and send it to the trash or install a plugin that will do the trick. Clearly the former option isn’t going to work well for anyone and sometimes installing a plugin reduces the speed of the WordPress blog.

So the question is “how on earth can I delete tons of spam comments in one shot without manually deleting the comments or installing a plugin?” The answer is to empty the “wp_comments” table (assuming you’re using “wp_” as the prefix) in the database. Here’s how:

Note: Before following the steps below, please back up your database.

1. Visit phpMyAdmin and log in using your credentials.

2. Click on your WordPress database in the left column (if you don’t know the name of your database just open the “wp-config.php” file in any text editor and scroll down until you see “The name of the database for WordPress.” The database name will be directly below it.

3. Click the “SQL” icon located above the WordPress database name to launch the query window.

4. To delete all “approved” spam comments, copy and paste the following SQL statement into the query window and click “Go.” (Note: this option will delete all approved comments.)

1
DELETE from wp_comments WHERE comment_approved = '1';

5. To delete all “unapproved” spam comments, copy and paste the following SQL statement into the query window and click “Go.”

1
DELETE from wp_comments WHERE comment_approved = '0';

6. Done! All spam comments should be deleted!

Comment Section