StackSurfer
StackSurfer

Reputation: 79

Bulk delete WooCommerce products that do not have featured image

I own a site that have over 5000+ products imported and some of them do not have any images.

I would like to delete products that do not have any images and I was looking for some sort of bulk delete SQL command. Can it be done like that?

Brainstorming lead me to following sequence: create SQL command to assign no image products to certain category and then delete them manually from backend?

Any help would be greatly appreciated!

Upvotes: 0

Views: 818

Answers (1)

Dennis Seesing
Dennis Seesing

Reputation: 45

DELETE FROM wp_postmeta where post_id in (SELECT id
FROM   `wp_posts` 
WHERE  id NOT IN (SELECT post_id FROM `wp_postmeta` WHERE  `meta_key` ='_thumbnail_id') 
AND `post_type` = 'product' 
AND `post_status` = 'publish')

Upvotes: 1

Related Questions