坏蛋的博客

非淡泊无以明志 非宁静无以致远



bbpress批量删除垃圾帖子

当垃圾帖子上万之后,在WordPress后台删除显然就不现实了,于是直接执行SQL删除之:

DELETE FROM wp_posts WHERE post_status='pending'; # 删除所有待审核文章,因为bbpress是在post表里保存的帖子内容,所以此操作会删掉待审核的帖子
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL; # 删掉孤立的帖子元信息
DELETE tr FROM wp_term_relationships tr LEFT JOIN wp_posts wp ON wp.ID = tr.object_id WHERE wp.ID IS NULL; # 删掉孤立的term绑定信息

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code