How to Delete All Pending Spam 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.

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.  The base WordPress install only lets you “bulk delete” pending comments page by page (i.e. 20 at a time) on it’s default settings.  It is not difficult to imagine that this would be very time consuming to do.

Before (or after) deleting all your pending comments you may want to consider configuring your WordPress installation to help prevent spam comments. I have created a  detailed tutorial for this here.

There are a number of ways to delete all the pending comments; some more complex than offers. The easiest method is to change the default settings in WordPress itself to display 200 pending comments at any one time. If you have more than 200 comments, then the next best way is to use a WordPress plugin. I have covered these two options first.

If you are comfortable with MYSQL then you may want to follow the later methods, although I do think the plugin method is the easiest way to quickly delete the comments.

1. Delete All Pending and Spam Comments by Changing the Default Comments Per Page Setting in WordPress

By default, WordPress only lets you delete 20 pending or spam comments at a time. You can change this setting to up to 200.

How to Delete All Pending and Spam Comments by Changing the Default Comments Per Page Setting in WordPress
  1. In the WordPress Admin, go to the ‘Comments’ page
    The first step is to go to the comments management page.

    • In the left-hand menu, click the “Comments” menu item.
    In the WordPress Admin, go to the 'Comments' page
  2. Access the Settings by clicking on ‘Screen Options’
    • In the top right-hand of the screen you will see a link to show the “Screen Options”.
    • Click the link to show the settings.
    Access the Settings by clicking on 'Screen Options'
  3. Update the pagination to show 200 comments per page
    • Replace “20” with “200” in the Number of items per page box.
    • Click “Apply” to save the change.
    Update the pagination to show 200 comments per page
  4. Click on ‘Pending’ or ‘Spam’ to filter comments by type
    In order to delete pending or spam comments you must first filter the comments.

    • Click “Pending” or “Spam” depending on the comments you wish to delete.
    Click on 'Pending' or 'Spam' to filter comments by type
  5. Select and Delete the comments
    To delete the selected comments:

    • Select all the comments by clicking the box at the top of the first column.
    • In the drop-down box select “Move to Trash”
    • Click “Apply”
    Select and Delete the comments
  6. Empty Trash

    Using this method only moves the comments to the Trash, rather than delete them permanently.

    You will need to click on “Trash” and then “Empty Trash” to finalize the deletion.

    Empty Trash

2. Delete All Pending Comments in WordPress using a Plugin

Using the Delete All Comments Easily plugin is the least technical and easiest way to delete significant numbers of pending comments in WordPress. I highly recommend using this method if you have more than 200 pending comments.

How to Delete All Pending Comments in WordPress using a Plugin
  1. In WordPress click ‘Add New’ under the Plugins menu
    The first step is to install the plugin from within the WordPress Admin Dashboard.

    • In the left-hand menu, under “Plugins” click “Add New”.
    In WordPress click 'Add New' under the Plugins menu
  2. Search for the ‘Delete All Comments Easily’ Plugin
    In the top right-hand of the screen you will see a Search Box.

    • Type in the name of the plugin in to the search box. The page will automatically update with the results.
    Search for the 'Delete All Comments Easily' Plugin
  3. Install the Plugin
    • Install the plugin by clicking on the “Install Now” button.
    Install the Plugin
  4. Activate the Plugin
    • Activate the plugin by clicking on the “Activate” button.
    Activate the Plugin
  5. Navigate to the Plugin Settings
    • You will find the plugin settings under the “Tools” menu.
    • Proceed to the settings page

    You will have to click the Tools menu item before the menu is expanded.

    Navigate to the Plugin Settings
  6. Delete all pending comments

    The final step is to delete the pending comments. You will see the number of comments, and number of pending comments clearly displayed.

    • Check the box next to “Delete all pending comments”, and click the button below.

    You will then see a notice stating the “All Pending comments have been deleted.”

    Delete all pending comments

3. Deleting all 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:

How to Delete all Pending Comments in WordPress Manually via SSH
  1. Log in to your website server via SSH.
    Many hosts now offer SSH access, but for security reasons you may have to request access.
  2. Run the following SQL command
    mysql -uDB_USERNAME -pDB_USER_PASSWORD -DYOUR_WORDPRESS_DB_NAME -e "DELETE
    FROM wp_comments WHERE comment_approved = '0';"

    Don’t forget to replace your DB_USERNAME, DB_USER_PASSWORD, an YOUR_WORDPRESS_DB_NAME with your sites details.

    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. 

    Run the following SQL command

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';"

4. Deleting Pending Comments in WordPress Manually via phpMyAdmin

Another way to do this, is to use phpMyAdmin:

How to Delete all Pending Comments in WordPress Manually via phpMyAdmin
  1. Login to your cPanel or other Control Panel
    Login to your cPanel Account and select the phpMyAdmin in the Database section
  2. Select your database
    Select the Database for your WordPress installation.
  3. Click the SQL tab and run the following command

      DELETE from wp_comments WHERE comment_approved = '0'
      

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

    Click the SQL tab and run the following command

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'
Jonathan Griffin. Editor @ The Webmaster

About the author

Editor, Hosting Expert, SEO Developer, & SEO Consultant.

Jonathan is currently the Editor & CEO at The Webmaster. He is also an SEO Developer offering consultancy services, primarily to other web development companies. He specializes in the technical side of SEO, including site audits, development of SEO related features, and site structure & strategy.

In his spare time, Jonathan has a passion for learning. He regularly undertakes professional courses on subjects ranging from python, web development, digital marketing, and Advanced Google Analytics.

Read more about Jonathan Griffin on our About Page.