↑ ↓ select, Enter open, Esc close

Permanently delete all spam comments

Adjust the values, the command updates live
user@server
wp comment list --status=spam --format=ids --path=/var/www/vhosts/example.com/httpdocs | xargs -r wp comment delete --force --path=/var/www/vhosts/example.com/httpdocs

Collects the IDs of all comments with spam status and deletes them permanently with --force, bypassing the trash. xargs splits a very large number of IDs across several calls, and -r prevents a call when there are no matches. Useful when tens of thousands of spam comments have piled up.

Note: Check with wp comment count first how many comments are affected.

Also searched as

  • delete spam comments wordpress
  • remove thousands of spam comments
  • clean up wordpress comments

Related one-liners

All in WP-CLI

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.