Skip to content

Instantly share code, notes, and snippets.

@tuongpgjz
Created June 22, 2022 07:47
Show Gist options
  • Save tuongpgjz/f2e7bfdcaa86cdfa4882779a79bc3706 to your computer and use it in GitHub Desktop.
Save tuongpgjz/f2e7bfdcaa86cdfa4882779a79bc3706 to your computer and use it in GitHub Desktop.
Delete trash product by mysql
-- Delete product variants
DELETE FROM wp_posts WHERE post_type = 'product_variation' AND post_parent IN (DELETE FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash');
-- Delete main product
DELETE FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash';
-- clean metapost
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment