How To Delete All Comments in WordPress


By Toni on August 12th, 2008 in Tips & Tutorials, Wordpress

I’ve been doing some webmaster maintenance – backups, software upgrades, etc. and ran into a WordPress install that had over 20,000 comments sitting in moderation. Ooops.

Unfortunately, WordPress provides no simple way of cleaning up huge amounts of comments. Mass edit mode is limited to the number of entries that can be deleted at once. Mass edit mode would be so much cooler if it had a big shiny button that says “Delete All Comments Awaiting Moderation”, don’t ya think?

Anyways, since I’ve faced similar problems in the past, I figured I would post my solution for our readers and anyone else looking for a quicker way to clear huge amounts of comments from a WordPress install:

To Delete All Comments Awaiting Moderation in WordPress:

(Remember to make a backup of your DB first)

From phpmyadmin, select your WordPress database, click the sql tab, and enter the following query:

SELECT *FROM wp_comments WHERE comment_approved ="0"

That will select all the un-moderated comments. Then enter this query:

delete from wp_comments WHERE comment_approved ="0"

Voila. Run a check and repair on the WordPress database afterwards to be sure everything is working fine.

This solution has worked for me on various versions of WordPress, and saved me hours of manual “mass edits”.

Related posts:

  1. Reader Question: FileZilla Account Logontype Shealee wrote: What is the account file in FileZilla’s site...
  2. DreamHost One Click Installs DreamHost offers one click installs for a stack of open...
  3. WordPress on DreamHost – Tutorial Just stumbled upon this nice video tutorial for setting up...
  4. FileZilla FTP Basics Flash video tutorial teaching you how to download, install and...
  5. Vanilla 1.01 Install at DreamHost Create a new MySQL database from your Dreamhost web panel....


Tags:  

Subscribe and get $750 of webmaster freebies

  • $149 of discounts at DreamHost, HostGator & JumpLine
  • $320 free advertising at Yahoo!, Ask.com & more
  • Free trials for Mozy, WordTracker & dozens more

(We hate spam, and we'll never sell, rent or otherwise misuse your personal details - see our privacy policy)


One Comment to “How To Delete All Comments in WordPress”

  1. [...] lived to tell the tale. Thanks to this guy for the [...]

What Do You Think?

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes