Friday, August 28, 2015

Delete all pending/spam/trash comments from WordPress (Single or Multisite) using WP-CLI

I just wrote this bash shell script to delete all pending/spam/trash comments from WordPress (Single or Multisite) using WP-CLI:



Put the script inside your WordPress root and run:

$ ./clean_comments.sh

These are available statuses of a comment:

  • approve: approved comments
  • hold: pending comments
  • spam: spams
  • trash: comments in the trash bin


This is pretty neat huh?!