Woocommerce | Delete all products at once
Remove all WooCommerce products ( at once ) is a good thing when you have got thousands of products and don’t want to pass page by page, for delete all posts.
Best things to do is use PhpMyAdmin and send a query that removes all posts at once.
Here the steps:
- Login to PhpMyAdmin
- Choose the right DB
- Backup the DB
- Select table “wp_posts” (if you have wp prefix)
- Run the SQL statement
Here the query :
If you have different wp prefix, change it in the query ( wp_term_relationships, wp_term_taxonomy, wp_terms, wp_postmeta, wp_posts, wp_posts )
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';
After execute this SQL statement verify if your products are deleted.
And if you want to remove the images that was associated with the delated posts ?
Simply install the plugin “Media Cleaner – Clean & Optimize Space” that ” Cleans your Media Library from the media entries (and files) which aren’t used in your website”.
that’s all