Skip to content

Instantly share code, notes, and snippets.

@ethanpil
Created July 24, 2014 21:56
Show Gist options
  • Save ethanpil/51b2aae90c55d1a99ea7 to your computer and use it in GitHub Desktop.
Save ethanpil/51b2aae90c55d1a99ea7 to your computer and use it in GitHub Desktop.
Delete all WooCommerce Products from Wordpress Database
-- Delete all WooCommerce Products from Wordpress Database
-- Thanks to http://www.kc-webdesign.co.uk/e_commerce/woocommerce-how-to-delete-all-products/
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment