OhhMuaOhhMua
  • Home
  • Hosting
    • Best Web Hosting
    • Free Web Hosting
    • VPS Hosting
  • WordPress
    • Solutions & Troubleshooting
    • Installation & Setup
    • Themes & Plugins
    • Security
  • Computer Tips
    • Gaming Errors & Solutions
    • PC Troubleshooting
    • Computer Hardware
  • Coupons & Deals
  • Contact Us
  • veo3 prompt generator
Reading: Delete Thousands of Spam Comments in 1 Second with WP CLI
Share
Notification Show More
Font ResizerAa
OhhMuaOhhMua
Font ResizerAa
  • Computer Tips
  • Hosting
  • WordPress
Search
  • Home
  • WordPress
    • Installation & Setup
    • Security
    • Solutions & Troubleshooting
    • Themes & Plugins
    • Troubleshooting
  • Hosting
    • Free Web Hosting
    • VPS Hosting
    • Best Web Hosting
  • Computer Tips
    • PC Troubleshooting
    • Gaming Errors & Solutions
    • Computer Hardware
  • Coupons & Deals
  • veo3 prompt generator
Have an existing account? Sign In
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

ohhmua
Last updated: September 12, 2024 4:02 pm
ohhmua
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?

You Might Also Like

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

Cannot Fetch Sitemap in Google Search Console

Discovered – Currently Not Indexed in Google Search Console: What It Means & How to Fix It

Why 2 Backlinks per Article Might Be Killing Your SEO

What is Obsidian? Why Developers Love This Note-Taking App

TAGGED:delete spam commentswp cli
Share This Article
Facebook Twitter Email Print
Leave a comment Leave a comment

Leave a Reply Cancel reply

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

Trending

Create a Simple Incrementing Number Effect with HTML and JavaScript 2
Solutions & Troubleshooting

Create a Simple Incrementing Number Effect with HTML and JavaScript

September 17, 2024
5 Signs Your SSD is About to Fail and How to Extend Its Lifespan
Computer Hardware

5 Signs Your SSD is About to Fail and How to Extend Its Lifespan

August 6, 2020
5 Signs It's Time to Upgrade Your Computer 5
Computer Tips

5 Signs It’s Time to Upgrade Your Computer

July 24, 2023
Why Your Computer Is Slowing Down
PC Troubleshooting

Why Your Computer Is Slowing Down — And the 5 Fixes Tech Pros Swear By

May 21, 2025
Detailed Guide to Updating Gigabyte BIOS
Computer Tips

Detailed Guide to Updating Gigabyte BIOS

July 31, 2024
Guide to Using Multiple Domains for One WordPress Website
Solutions & Troubleshooting

Guide to Using Multiple Domains for One WordPress Website

September 16, 2024
Previous Next

You Might Also Like

Optimize WordPress
Solutions & Troubleshooting

Want Faster Load Times? Optimize WordPress This Way

May 16, 2025
My Google Discover traffic skyrocketed after I did these 10 things
Solutions & Troubleshooting

My Google Discover traffic skyrocketed after I did these 10 things

May 14, 2025
How to Add a Read More to Product Descriptions in WooCommerce
Solutions & Troubleshooting

How to Add a “Read More” and “Show Less” Button to Product Descriptions in WooCommerce

May 5, 2025
WordPress Covers Every Website Type
Solutions & Troubleshooting

Blog, E-Commerce, or Forum? WordPress Covers Every Website Type!

April 29, 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
Welcome Back!

Sign in to your account

Lost your password?