Mass Delete WordPress Pending SPAM Comments

There may be times when certain comments pass by your WordPress SPAM filter and end up in your pending comments section. You can bulk edit the comments for deletion but that’s usually a page at a time, which is fine for 50-100 pending comments but what happens when you have upwards of 1000 pending comments to delete…or in my friend’s case 5500+ comments. Lucky for us you can mass delete WordPress pending SPAM comments with one simple SQL query.

Log into phpMyAdmin
This can usually be done via your hosts control panel. If you have no idea where to find it, just go to your hosts help section and search for phpMyAdmin and follow the instruction of how to launch it. What is phpMyAdmin…well it lets you administer your MySQL servers which contain all of your WordPress information.

Select your WordPress database

Choose your WordPress install’s database. If you only have one database, you are all set. If you have multiple databases there will be a dropdown on the left hand side in which you can choose the database that contains all of the pending comments. The default WordPress install extension for tables is wp_, so when you choose your database on the left hand, your WordPress tables will display on the right. Also some plugins will write to your database, so you may notice some plugins names in the table to the right.

Enter and run your SQL query
The default view of your database is the “Structure” tab, this tab displays all your tables. We need to work in the “SQL” tab so navigate a tab over and you will be presented with a box labelled:
“Run SQL query/queries on database yourdatabasename”

This box is where the magic happens but before proceeding let’s just make sure we are in the correct database. On the left you will see your database name in two places, in the drop-down box as well as underneath the drop-down. On the right side you will also see your database name in two locations, on the very top in the breadcrumb and right above the text box in the heading that reads: “Run SQL query/queries on database yourdatabasename.” Once you are confident that you are in right database, paste the following into the text box.
DELETE FROM wp_comments WHERE comment_approved = ‘0’
The above basically means delete all pending comments (comments marked 0) from the wp_comments table.

Once you are all set to run your query, cross your fingers and click go. You may be prompted with a “Are you sure” popup box, just click yes and if all goes well you will be presented with a green highlighted status box that gives you the rundown of your query.



If your query was successful now when you log into your WordPress admin panel you will see that all of your previous pending comments have now been deleted, enjoy!

About Gabe Diaz

Gabe Diaz is web professional and consultant focusing on design and development, currently based out of South FL. When not geeking out on the internet you will find him spending time with his children. You can also find him on Google+: +Gabe Diaz, Twitter: @GabeDiaz and Facebook: GabeDiaz.

31. August 2010 by Gabe Diaz
Categories: Blog | Leave a comment

Leave a Reply

Required fields are marked *