How to Mass Delete Pending Comments in WordPress

Web Development Menu

With WordPress Comment Spam increasingly becoming an issue you might find yourself with 100’s or even 1000s of pending comments that you then need to delete.  Unfortunately, the base WordPress install only lets you “bulk delete” pending comments page by page (i.e. 20 at a time).  It is not difficult to imagine that this would be very time consuming to do.

Before (or after) deleting the pending comments you may want to consider configuring your WordPress install to help prevent spam comments, and we have created a  detailed tutorial for this here.

Fortunately, there is an easy way to Delete Pending Comments in WordPress.  In fact, you have a few choices on how you go about doing it:

1. Deleting Pending Comments in WordPress Manually via SSH

For those a little more technically minded and don’t mind logging in via SSH and using the command line it is very easy to Delete all your Pending Comments.  Just follow these instructions:

  1. Log in to your website server via SSH.  Some hosts will disable this by default, but will allow access upon request.
  2. Run the following command:
 
mysql -uDB_USERNAME -pDB_USER_PASSWORD -DYOUR_WORDPRESS_DB_NAME -e "DELETE 
FROM wp_comments WHERE comment_approved = '0';"
Delete pending comments SSH.
Delete pending comments SSH. © The Webmaster.

If you used Softaculous, or another installer, to install WordPress, you would have received a confirmation after the install was complete with all the information you will need to run this command.  Otherwise, you will hopefully have made a record of it when you installed it manually.

This command can be adapted with one minor change to carry out other comment related tasks:

Mass Delete all Approved Comments in WordPress via SSH

 
mysql -uDB_USERNAME -pDB_USER_PASSWORD -DYOUR_WORDPRESS_DB_NAME -e "DELETE 
FROM wp_comments WHERE comment_approved = '1';"

Mass Delete all Spam Comments in WordPress via SSH

 
mysql -uDB_USERNAME -pDB_USER_PASSWORD -DYOUR_WORDPRESS_DB_NAME -e "DELETE 
FROM wp_comments WHERE comment_approved = 'spam';"

Mass Delete all Trash Comments in WordPress via SSH

 
mysql -uDB_USERNAME -pDB_USER_PASSWORD -DYOUR_WORDPRESS_DB_NAME -e "DELETE 
FROM wp_comments WHERE comment_approved = 'trash';"

2. Deleting Pending Comments in WordPress Manually via phpMyAdmin

Another way to do this, is to use phpMyAdmin:

  1. Login to your cPanel Account and select the phpMyAdmin in the Database section
  2. Select your database
  3. Click the SQL tab and run the following command:
 
DELETE from wp_comments WHERE comment_approved =  '0'
Delete pending comments sql.
Delete pending comments sql. © The Webmaster.

When you run the command, you will get a pop-up box asking for confirmation.  Just click “OK”.

You can use this technique to carry out other similar tasks with just one very minor alteration to the command used:

Mass Delete all Approved Comments in WordPress via SQL

 
DELETE from wp_comments WHERE comment_approved =  '1'

Mass Delete all Spam Comments in WordPress via SQL

 
DELETE from wp_comments WHERE comment_approved = 'spam'

Mass Delete all Trash Comments in WordPress via SQL

 
DELETE from wp_comments WHERE comment_approved = 'trash'

3. Deleting Pending Comments in WordPress using a Plugin

This is probably the least technical way to delete your pending comments in WordPress, and one of the easiest.  Simply install the Delete Pending Comments Plugin.  The easiest way to install the plugin is to go to the Plugins page in the Admin panel and then search for “Delete Pending Comments”.  The plugin we recommend is the first one listed, although you will see several others that could be used.

Delete pending comments plugin.
Delete pending comments plugin. © The Webmaster.

Once installed, activate the plugin.

Under the Comments Menu in WordPress, you will see a sub-menu item to “Delete Pending Comments.“  Once clicked you will be taken to the confirmation screen checking that you do indeed wish to delete all your pending comments.  To confirm you will need to type some text in the box to confirm.

Delete Pending Comments confirmation
Delete Pending Comments confirmation. © The Webmaster.

If successful, you will get a message saying “I deleted all pending comments!”.

Jonathan Griffin. Editor @ The Webmaster

About the author

Editor at The Webmaster.

Jonathan Griffin has been the Lead writer at The Webmaster for the last 5 years. Having provided technical SEO, WordPresss development, and hosting services for clients, his passion remains to help small businesses and bloggers develop their online presence.

In his spare time, he loves to push his technical knowledge further, and regularly undertakes professional courses on subjects ranging from python development, digital marketing, and Google Analytics.

Find out more about Jonathan Griffin on our About Page.