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

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

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

How I Optimized Pagination and Skyrocketed Traffic

How to Pick the Ideal Blogging Platform for Your Needs

Protecting Your WordPress Site from File Upload Vulnerabilities

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 Stories

How to fix something went wrong in game uncharted 4
Gaming Errors & Solutions

How to fix something went wrong in game uncharted 4

September 23, 2024
Battlefield 1 fix error First time launching 2
Gaming Errors & Solutions

Battlefield 1 fix error First time launching and can’t click “OK” on initial splash screen

September 23, 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
power supply
Computer Tips

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

July 26, 2023
Script Hook V Critical Error Fix
Gaming Errors & Solutions

How to Fix Script Hook V Critical Error in GTA 5 [TESTED]

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

Detailed Guide to Updating Gigabyte BIOS

July 31, 2024

You Might Also Like

Title and Meta Description Mismatch on Google
Solutions & Troubleshooting

Title and Meta Description Mismatch on Google[How to fix]

September 25, 2024
Contact button
Solutions & Troubleshooting

Contact button in the footer with added call button shake effect

September 21, 2024
Guide to Creating a Beautiful Promotion Notification Box for Your Website
Solutions & Troubleshooting

How to Create a Stunning Notification Box for Your Website

September 20, 2024
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
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?