Some blogs receive more spam than others for whatever reason, and these can get into your “pending” queue. If you don’t clean them out regularly, they will quickly build up to thousands of comments cluttering up your database and your comments section. Unfortunately, unlike the “Spam” and “Trash” sections of the current administration screen, there is no single “Empty” button to delete all of them at once. You’re forced to go through them page by page. There’s not even an option to change the number of comments displayed in a single section! So if you want to quickly be rid of all of them at once, you have to use an external third-party tool. There are two ways to do this – either using a plug-in, or by accessing the phpMyAdmin database itself. So here’s how to delete all WordPress comments quickly in one stroke.
Accessing the backend database that powers WordPress is a risky affair. If something goes wrong, you’d better hope and pray that you have a backup. Having thrown out that caveat, it’s also an extremely powerful tool. You can manipulate just about everything from here including deleting a bunch of comments. Login to your cPanel administration interface and search for “phpMyAdmin”. I’d earlier written a post on how to change your username and password using the database. You can find screenshots on how to access it over there.
Once you select the database relevant to your blog, click the “wp_comments” table on the left hand side.
This will bring up all the records associated with your comments. As you can see, each has a number of fields attached to it. If you scroll over to the right, you’ll see a field called “comment_approved” with values of either 1 or 0.
“Pending” comments have a value of 0 and those that have been approved are 1. So to delete all pending comments in WordPress, we merely have to specify records with a “comment_approved” value of 0.
To do this, click the “SQL” tab as shown in the screenshot below.
You will see a text area where you can type in SQL commands. To remove all pending comments, use the following:
DELETE FROM wp_comments WHERE comment_approved = 0
Hit “Go” on the bottom right and the command will execute. That’s it! In one stroke, you’ve deleted hundreds or possibly thousands of records.
You can extend this functionality to remove ALL WordPress comments entirely. You may have decided to go down the “I don’t care about comments!” path, or chosen to convert your blog into a corporate website. Whatever the reason, you can achieve this by typing in the following:
DELETE FROM wp_comments
When we remove the conditional “WHERE” clause, it targets all the records in the database. In one fell swoop, you’ve removed every single comment in your database. If you think about it, that’s pretty scary. Always make sure you have a backup to restore if you mess up big time.
Using a Plugin
If the thought of fiddling with a database backend scares you (and no shame if it does), you can just install a plugin like Delete All Comments instead. After installation, go to the “Tools” menu and check the box to delete everything. After you’re done, you can uninstall the plugin without leaving a trace.
More and more sites these days are deciding to go comment free – while I personally don’t think that this is a trend in the larger scheme of things, there’s no doubt that it makes sense for a few specialized sites like those focusing on science and technology for example or corporate pages. If you decide to go down a similar path, these two techniques to delete all of your comments will surely come in handy.