批量删除woocommerce产品和目录脚本

admin

Administrator
管理成员
打开终端连接你要删除产品的数据库
Bash:
mysql -u username -p -h hostname jsanchezperez_es
然后输入密码确定即可
执行以下SQL语句:
SQL:
-- 删除产品的元数据
DELETE pm
FROM wp_postmeta pm
JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.post_type = 'product';

-- 删除产品的评论(如果有)
DELETE c, ct
FROM wp_comments c
LEFT JOIN wp_commentmeta ct ON c.comment_ID = ct.comment_id
JOIN wp_posts p ON c.comment_post_ID = p.ID
WHERE p.post_type = 'product';

-- 删除产品的分类关系
DELETE tr
FROM wp_term_relationships tr
JOIN wp_posts p ON tr.object_id = p.ID
WHERE p.post_type = 'product';

-- 删除产品
DELETE FROM wp_posts
WHERE post_type = 'product';

最后执行exi退出即可
 
后退
顶部