Created
June 22, 2022 07:47
-
-
Save tuongpgjz/f2e7bfdcaa86cdfa4882779a79bc3706 to your computer and use it in GitHub Desktop.
Delete trash product by mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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