OhhMuaOhhMua
  • Home
  • WordPress
    • Solutions & Troubleshooting
    • Installation & Setup
    • Themes & Plugins
    • Security
  • Tools
    • veo3 prompt generator
  • Our Team
  • Hosting
    • Best Web Hosting
    • Free Web Hosting
    • VPS Hosting
Reading: Delete Thousands of Spam Comments in 1 Second with WP CLI
Notification Show More
OhhMuaOhhMua
  • WordPress
  • Entry-level Builds
  • High-end Builds
  • Mid-range Builds
  • Hardware Tips
  • Software Tips
Search
  • Home
  • WordPress
    • Installation & Setup
    • Security
    • Solutions & Troubleshooting
    • Themes & Plugins
  • Tools
    • veo3 prompt generator
  • Our Team
    • Hosting
Follow US
Copyright © 2024 ohhmua. All rights reserved.
OhhMua > Blog > WordPress > Solutions & Troubleshooting > Delete Thousands of Spam Comments in 1 Second with WP CLI
Solutions & Troubleshooting

Delete Thousands of Spam Comments in 1 Second with WP CLI

Admin (Nghia Vo)
Last updated: September 12, 2024 4:02 pm
Admin (Nghia Vo)
Share
2 Min Read
How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress
How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress
SHARE
Contents
Step 1: Open the terminalStep 2: Navigate to the website’s root directoryStep 3: The key step – Enter the command to delete spam comments

If you only have a few spam comments, deleting them through the admin panel is quick. But if your website has thousands or even tens of thousands of spam comments, like in the example image, the following method will help you delete them quickly and easily.

How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress
How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress

In this guide, I’ll use WP CLI to delete comments and execute the commands in the terminal.

  • If you are using a VPS, log in via SSH to proceed.
  • If you are using hosting, your hosting provider must support terminal access for this to work. In Vietnam, I’ve noticed that providers like Azdigi and iNet offer terminal access in some of their premium plans.
spam comments
spam comments

Step 1: Open the terminal

On cPanel hosting, you will find the terminal interface as shown in the image below.

How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress 2
How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress

Step 2: Navigate to the website’s root directory

Identify the root directory of the website where you want to delete spam comments, then type the following command and press Enter:

For example, if your website is located in the public_html folder, you would type:

cd public_html
How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress 3
How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress

Step 3: The key step – Enter the command to delete spam comments

wp comment delete $(wp comment list --status=hold --field=ID --allow-root) --force --allow-root

In this command:

  • --status=hold can be replaced with other statuses like approved (approved), spam (marked as spam), trash (moved to trash), or hold (pending approval).

After hitting Enter, the system will delete all spam comments. Deleting 3,000 spam comments only takes 1-2 seconds. Pretty fast, right?

480520387 657957633334779 6814038772835954285 n
Admin (Nghia Vo)

Hi, I’m Nghia Vo: a computer hardware graduate, passionate PC hardware blogger, and entrepreneur with extensive hands-on experience building and upgrading computers for gaming, productivity, and business operations.
As the founder of Vonebuy.com, a verified ecommerce store under Vietnam’s Ministry of Industry and Trade, I combine my technical knowledge with real-world business applications to help users make confident decisions.

I specialize in no-nonsense guides on RAM overclocking, motherboard compatibility, SSD upgrades, and honest product reviews sharing everything I’ve tested and implemented for my customers and readers.

You Might Also Like

Headless vs Traditional WooCommerce: Which Architecture Wins?

Can AI Agents Safely Access Your WordPress Site?

Is WordPress Dead or Still Powering the Web in 2026?

WordPress 6.9.2 Disaster: Why You Should Never Auto-Update Immediately

Headless WordPress Explained: Is It Right for Your Site?

TAGGED:delete spam commentswp cli
Share This Article
Facebook Twitter Email Print
By Admin (Nghia Vo)
Follow:
Hi, I’m Nghia Vo: a computer hardware graduate, passionate PC hardware blogger, and entrepreneur with extensive hands-on experience building and upgrading computers for gaming, productivity, and business operations. As the founder of Vonebuy.com, a verified ecommerce store under Vietnam's Ministry of Industry and Trade, I combine my technical knowledge with real-world business applications to help users make confident decisions. I specialize in no-nonsense guides on RAM overclocking, motherboard compatibility, SSD upgrades, and honest product reviews sharing everything I’ve tested and implemented for my customers and readers.
Leave a comment Leave a comment

Leave a Reply Cancel reply

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

Trending

How to Make Google Understand and Value Your Content
Solutions & Troubleshooting

SEO in the Age of AI: How to Make Google Understand and Value Your Content

June 5, 2025
Share a countdown button to display a password in WordPress
Solutions & Troubleshooting

Share a countdown button to display a password in WordPress

September 11, 2024
Top WordPress Themes for Bloggers in 2025
Themes & Plugins

You Won’t Believe These Are Free! Top WordPress Themes for Bloggers in 2025

April 30, 2025
Internet Connected But Can't Access Some Websites
Software Tips

Internet Connected But Can’t Access Some Websites: Causes and Fixes

September 25, 2020
How to Install WordPress on cPanel
Installation & Setup

How to Install WordPress on cPanel: A Beginner-Friendly Guide

April 24, 2025
Change 0 Price or Empty Price to 'Call for Price' in WooCommerce
Solutions & Troubleshooting

Change 0 Price or Empty Price to ‘Call for Price’ in WooCommerce

September 7, 2024
Previous Next

You Might Also Like

WordPress 7.0 Finally Fixes 20 Years of Painful Collaboration Problems
Solutions & Troubleshooting

WordPress 7.0 Finally Fixes 20 Years of Painful Collaboration Problems

Admin (Nghia Vo) Admin (Nghia Vo) March 9, 2026
HETZNER HOSTING
Solutions & Troubleshooting

Why Hetzner Might Not Be the Right Choice for Beginners

Admin (Nghia Vo) Admin (Nghia Vo) March 7, 2026
wordpress speed 2026
Solutions & Troubleshooting

WordPress Speed in 2026: The Only Hosting Checklist You Need

Admin (Nghia Vo) Admin (Nghia Vo) March 7, 2026
What Happens When Web Hosting Companies Get Acquired
Solutions & Troubleshooting

What Happens When Web Hosting Companies Get Acquired

Admin (Nghia Vo) Admin (Nghia Vo) March 6, 2026
wordpress shortcode 1
Solutions & Troubleshooting

WordPress Shortcodes: Complete Guide to Dynamic Content

Admin (Nghia Vo) Admin (Nghia Vo) March 4, 2026
Cannot Fetch Sitemap in Google Search Console
Solutions & Troubleshooting

Cannot Fetch Sitemap in Google Search Console

Admin (Nghia Vo) Admin (Nghia Vo) May 27, 2025
Previous Next
newsletter featured

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Youtube Steam Twitch Unity

Copyright © 2024 ohhmua. All rights reserved.

OhhMua

Information

  • About
  • Terms & Conditions
  • Privacy Policy
  • Editorial Standards
Welcome Back!

Sign in to your account

Lost your password?