这是删除所有后期修订的常见查询:
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = \'revision\'
这是否可以删除所有草稿?
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = \'draft\'
既然它也删除了Posteta,那么它是否比这更好呢?
DELETE FROM posts WHERE post_status = ‘draft’
最合适的回答,由SO网友:Jacob Peattie 整理而成
draft
不是post_type
, 这是一个post_status
. 因此,您应该将第二块代码用于该替换:
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_status = \'draft\'
SO网友:Sumit Jangir
I would suggest if u want to delete any post manually from wp_posts. you need to perform the following steps:-
- Remove from postmeta table.
delete FROM wp_postmeta WHERE post_id IN
(
select id from wp_posts where post_status=\'draft\'
);
- Remove from wp_term_relationships table.
delete FROM wp_term_relationships WHERE object_id IN
(
select id from wp_posts where post_status=\'draft\'
);
- Remove from wp_posts table.
delete from wp_posts where post_status=\'draft\'