I would like to know how to bulk delete posts from a specific category using the WP-CLI, any tip?
This should delete all posts in your category:
wp post delete $(wp post list --cat=your_category_ID --format=ids)
Or directly:
wp db query [<your_sql_query>]
For more info:
wp post delete --help
wp post list --help
wp db query --help
Actually update wp-cli needs to use the following command to delete all products for a category of Woocommerce installation:
wp post delete $(wp wc product list --category=category_id --user=admin_username) --force
Since Woo only allows to delete 100 products per time you can use the following bash command to create loops using a step value of 100.
for run in {1..2}; do wp post delete $(wp wc product list --category=category_id --user=admin_username) --force; done
this one deletes 200 products in 2 steps of 100 product each
for run in {1..3}; do wp post delete $(wp wc product list
--category=category_id --user=admin_username) --force; done
this one deletes 300 products in 3 steps of 100 product each
and so on...