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
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
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

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

Want Faster Load Times? Optimize WordPress This Way

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

admin wordpress dashboard
Themes & Plugins

Introduction to the WordPress Dashboard: Features, Tools, and Navigation

April 25, 2025
power supply
Computer Tips

How Many Watts Does Your Computer Power Supply Need? Understand to Choose Correctly

July 26, 2023
update bios Should and Shouldn't
Computer Hardware

Real Experience: I Updated My BIOS and Almost Lost My Motherboard

April 15, 2025
How to Choose the Right Motherboard for Intel 14th Gen Processors
Computer Hardware

How to Choose the Right Motherboard for Intel 14th Gen Processors

April 22, 2025
Top Free WordPress Plugins for Bloggers in 2025
Themes & Plugins

Top Free WordPress Plugins for Bloggers in 2025

May 3, 2025
How to Change WordPress Login URL Without Plugins
Solutions & Troubleshooting

How to Change WordPress Login URL Without Plugins (100% Success)

September 9, 2024
Previous Next

You Might Also Like

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
Optimized Pagination thumbnail
Solutions & Troubleshooting

How I Optimized Pagination and Skyrocketed Traffic

April 28, 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?