When comments come in for your WordPress blog, they can be one of these three categories.
- Approved comments – WordPress has detected that these comments are real comments, and has immediately approved these comments
- Pending comments – These comments pass the spam filter, but either WordPress feels they they are some sorta “non human”, or it violates some of the rules you have laid in the blog discussion settings.
- Spam comments – If you have the very handy Akismet in place, commented identified as spam will go direct to spam comments.
If your blog is popular to any extent, you can expect to receive a lot of spam comments. These are easy to clear. All you have to do is to click on Comments -> Spam from your WordPress admin page, and you can clear them in one go, with the “Delete all Spam” button.
However, the issue comes when hundreds, or thousands of comments come in and they go into your moderation queue. This means they pass the spam filter.
WordPress allows you to mass delete these comments in the wp-admin – but only in batches of 20 at a time. When you have 853 comments waiting for “moderation”, well, you will start to realise batch deleting in 20s might not be a good idea (you have to do it over 40 times!)
Fortunately, there is a (somewhat) simpler way to do this.
Here are the steps.
#1 Log In to Your Hosting Backend
In my case, and in huge percentage of web hosts around the world, we use CPanel. Depending again on your hosting provider’s settings, the well-known way to access your CPanel is <yourdomain.com>/cpanel.
You will have to key in a username and password.
When you have successfully logged in, you will see a screen like this:
#2 Access Your Database Using phpMyAdmin
Look for the phpMyAdmin icon (under databases) and click on it. You should see a page like that when you are in the phpMyAdmin page.
Select your WordPress database by clicking on it on the left. You will see a list of tables within that database.
Next, locate the tabs on the right side, and find “SQL”. Click on that.
You will see this screen.
#3 Run the Following SQL command on your database
The command is this:
DELETE FROM wp_comments WHERE comment_approved = '0'
You should see a status message saying something like “853 rows affected”.
Then, you are done! Log back in to your WordPress admin panel, and you will find all the pending comments gone! Hurray!