«

»

Dec 16

Mass Remove WordPress Comments

I had an issue with some comment spam and ended up with a little over 30,000 comments between unapproved, spam, and trash in my WordPress comments – FTW! Would have taken me a week to move them all to trash and then delete them. Here is a quick way to mass delete comments using SQL queries in phpMyAdmin.

You may want to make sure you have a good backup of your database. A typo in one of these SQL queries could end up being a disaster.

In phpMyAdmin select your WordPress database and then click the SQL tab.

This query will delete all unapproved comments. It does not send them to trash or mark them as spam, it deletes them. The comments will be gone forever.

delete from wp_comments WHERE comment_approved ="0"

To quickly delete all comments marked as spam run this query:

delete from wp_comments WHERE comment_approved ="spam"

To quickly delete all comments in trash run this query:

delete from wp_comments WHERE comment_approved ="trash"

Hopefully you won’t find yourself in a position where you need to delete over 30,000 comments but if you do this should help.

About the author

vHersey

Hersey Cartwright is an IT professional with extensive experience designing, implementing, managing, and supporting technologies that improve business processes. Hersey is Solutions Architect for SimpliVity covering Virginia, Washington DC, and Maryland. He holds the VMware Certified Design Expert (VCDX-DV #128) certification. Hersey actively participates in the VMware community and was awarded the VMware vExpert title in 2016, 2015, 2014, 2013, and 2012. He enjoys working with, teaching, and writing about virtualization and other data center technologies. Follow Hersey on Twitter @herseyc

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

19 − 4 =