How can I delete many WordPress comments or posts that spammers have added?
One of the features of WordPress is that other people can add comments or other content to your site (if you’ve set it up that way).
However, we occasionally hear from customers who tell us that they enabled comments (or even allowed people to register and contribute posts), then didn’t look at the site for a while — and now they have many spam comments or posts that they need to delete.
You can easily delete small numbers of comments or posts from the WordPress dashboard. (The “Comments” page shows only 20 comments by default, but you can increase that by clicking Screen Options in the top-right.)
If you have a large number, though, you may find these plugins useful to delete them:
- Disable Comments: Completely removes all comment features from WordPress, preventing anyone from adding any future comments anywhere in one step. Allows for bulk deletion of comments as well.
- Bulk Delete: Bulk deletes pending posts.
Advanced options
Advanced users can use the command line to quickly remove all comments directly from the database:
wp db connect truncate table wp_comments; truncate table wp_commentmeta; exit
Then afterwards you can run this command to reset the comment count on all posts and pages:
wp comment recount $(wp post list --post_type=page,post --format=ids)
You can run this command to “close” comments and pings on existing posts:
wp post update $(wp post list --format=ids) --ping_status=closed --comment_status=closed
And these commands to disable comments and pings on any future posts:
wp option set default_comment_status "" wp option set default_ping_status ""
Preventing future comment spam
WordPress has a number of features to prevent comment spam.
If you don’t want people posting any comments at all, you can disable the comment feature.
To do this for future posts or pages, click Settings > Discussion in the WordPress dashboard and uncheck the options that “Allow link notifications from other blogs (pingbacks and trackbacks)” and “Allow people to post comments on new articles”.
To stop new spam comments on existing posts, you can check the Automatically close comments on articles older than 14 days box. If you do this, and also block comments on all new posts as described above, spammers will soon not be able to post at all.
If you want more control over comments, many people find these WordPress plugins useful:
- Akismet: Automatically flags many comments as “spam”.
- WordPress ReCaptcha Integration: Makes visitors prove they’re human before allowing a comment.
The WordPress site has more tips to combat comment spam.
About the plugins
Just so it’s clear, we’re not the author of any of the plugins mentioned above. You should post on the WordPress forums if you have any questions.
Copyright © 2000-2024 Tiger Technologies LLC