WP CLI command to delete products from a specific category?

401 Views Asked by At

While the command to

DELETE ALL CATEGORIES IS - wp term list product_cat --field=term_id | xargs wp term delete product_cat

AND

DELETE ALL THE PRODUCTS IS - wp post list —field=ID —post_type=product | xargs wp post delete —force

what would be the command to select products from a specific category/categories and delete them.

Help much appreciated.

1

There are 1 best solutions below

0
On

You use the category specifier --category="your category".

For example wp post delete $(wp wc product list --user=1 --format=ids --category=64) --force.