DEV Community

Ko Takagi
Ko Takagi

Posted on

2 1

How to bulk delete huge post data in WordPress

That's a lot of work, deleting hundreds of thousands of huge post data.

Let's use the WP-CLI command to delete all those data at once.

How to use

Bulk delete all post data.

wp post delete $(wp post list --post_type='post' --format=ids) --force
Enter fullscreen mode Exit fullscreen mode

If you want to delete data from your custom post type, you can specify the post type in the post_type option

# Delete post type 'news'
wp post delete $(wp post list --post_type='news' --format=ids) --force
Enter fullscreen mode Exit fullscreen mode

If you have too much data to delete, you may get an Argument list too long error.

In that case, you can delete it little by little with a shell script like the following.

#!/bin/sh

# Deleting 10,000 at a time.
for i in `seq 1 10`
do
    wp post delete $(wp post list --post_type='your-post-type' --format=ids --posts_per_page=10000) --force
done

echo "done"
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more