Skip to content

Instantly share code, notes, and snippets.

@tuongpgjz
Last active June 23, 2022 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuongpgjz/b2453c4cb1e6b61e80e580c823304ea4 to your computer and use it in GitHub Desktop.
Save tuongpgjz/b2453c4cb1e6b61e80e580c823304ea4 to your computer and use it in GitHub Desktop.
Remove WooCommerce products by category name or a part of category name
-- replace category_name by your category name
DELETE FROM wp_posts WHERE ID IN (SELECT object_id from wp_term_relationships WHERE term_taxonomy_id IN(SELECT term_taxonomy_id FROM `wp_term_taxonomy` WHERE taxonomy = 'product_cat' AND term_id IN (SELECT term_id FROM `wp_terms` WHERE name like '%category_name%')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment