A client with a WooCommerce store asked me to bulk delete over 8,000 products because they were unable to do so within the WordPress Dashboard environment. Unfortunately, even if you highly increase your server’s PHP and timeout settings, you’ll find yourself once again with the same errors.
So, how can you bulk delete everything without getting an error? The answer is your database.
By copying, pasting, and running a simple SQL script, you can easily delete all your WooCommerce products within seconds.
You don’t need a high-end server or make any other adjustments whatsoever, and it’s the most pointless and fastest way to do this (believe me, I’ve tried everything else).
Unfortunately, it’s the perfect way of bulk deleting all products, but it’s good enough and it actually works.
How to bulk delete all WooCommerce products
1. The first thing that you’ll have to do is backup your website’s files and database. Do not say I didn’t warn you.
Τhis code will wipe out everything that has to do with WooCommerce products.
2. Access phpMyAdmin: If you’re using Plesk, you can find it under your website’s domain name: Dashboard -> Databases -> phpMyAdmin.
3. Click on “SQL Code” section, copy the SQL script provided below, and paste it inside.
-- 1. Delete term relationships (e.g., product categories, tags, attributes)
DELETE tr, tt, t
FROM 7AHiLbADe_term_relationships AS tr
LEFT JOIN 7AHiLbADe_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
LEFT JOIN 7AHiLbADe_terms AS t ON tt.term_id = t.term_id
WHERE tr.object_id IN (
SELECT ID FROM 7AHiLbADe_posts WHERE post_type IN ('product', 'product_variation')
);
-- 2. Delete product metadata (e.g., price, SKU, stock, etc.)
DELETE FROM 7AHiLbADe_postmeta
WHERE post_id IN (
SELECT ID FROM 7AHiLbADe_posts WHERE post_type IN ('product', 'product_variation')
);
-- 3. Delete products and variations from the main posts table
DELETE FROM 7AHiLbADe_posts
WHERE post_type IN ('product', 'product_variation');
4. Click on the “Run” button to bulk delete all your WooCommerce products.
I have commented on the code on what each line does. For example, if you don’t want to delete your product categories, tags, and attributes, don’t copy the first few lines.
Great, now if you access your WordPress site, WooCommerce should be empty and without any products. What’s still there are the images, which we can delete with a simple and free plugin.
What This Script Does:
- Deletes relationships between products and taxonomies (like categories, tags, product attributes).
- Deletes all metadata stored in
wp_postmeta
for products (such as price, stock, SKU, custom fields). - Deletes the actual products and their variations from the WordPress
posts
table.
This is used to completely remove WooCommerce products from a WordPress site at the database level, bypassing the admin UI and skipping the trash.
How to bulk delete all your images
Although the SQL script is a nice and fast way of removing all of our products, it doesn’t actually delete all the “leftovers”, which in our case are the images.
If you want to delete all the images (both for featured images and the ones inside the gallery), you can use a free and simple plugin.
- Install the Media Cleaner: Clean your WordPress! plugin.
- From your WordPress Dashboard, go to Media -> Cleaner.
- Click on “Scan” and wait until the process is completed.
- You can then bulk delete all your images, send them to trash, or choose which ones you want to keep.
Editor’s Note: Media Cleaner is a robust plugin, but sometimes it can’t recognize that some of our images are placed on menus, sidebars, etc. Please make sure that you have a backup before cleaning up everything.
Depending on the number of images and your server’s performance, it may take a while until the Media Cleaner plugin scans them all. But it’s the fastest and easiest way I’ve found as of this moment.
You can also use the WP-Optimize plugin to optimize your database, clean up all the revisions, and delete tables that you don’t need anymore.
I hope that helped you! But if you have any issues or you want help with anything WordPress-related, don’t hesitate to drop your comment down below.
Uh, oh! Legal stuff! Yikes.. Yet important! Affiliate Links Disclaimer: Many of the links on my articles are affiliate links. That means if you click on one and make a purchase, I might earn a small commission, and I'll keep doing what I'm doing, reviewing everything with absolute honesty. Sounds good? Good.