How to Mass Delete Pending Comments in WordPress

DEVELOPMENT

How to Mass Delete Pending Comments in WordPress

A detailed tutorial showing you How to Mass Delete Pending Comments in WordPress. We have included 3 different ways to do it: SQL, SSH & via plugin.

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 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

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

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

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

Related tags
Check out our top user-rated host: SiteGround
Need help choosing a hosting provider?
Check out our top user-rated host: SiteGround