批量删除WordPress指定类别文章

在后台虽然有批量删除WordPress文章的功能,但是每次最多200篇,而且需要手动删除,删除缓慢。下面是一种直接从数据库删除WordPress指定类别下全部文章的办法。

delete
from
wp_posts
using
wp_posts,
wp_term_relationships,
wp_term_taxonomy
where
wp_posts.id=wp_term_relationships.object_id
and
wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
and
wp_term_relationships.term_taxonomy_id = 1

获取term_taxonomy_id这个分类id 可通过文章->分类(假设删除懂得都懂下的分类)

获取tag_ID

将把上面的14换成你的分类或者标签id即可。



delete
from
wp_posts
using
wp_posts,
wp_term_relationships,
wp_term_taxonomy
where
wp_posts.id=wp_term_relationships.object_id
and
wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
and
wp_term_relationships.term_taxonomy_id = 14

如果同时需要删除分类,也可以执行sql命令,或者直接后台界面删除,分类删除还是比较简单。

delete FROM `wp_term_relationships` where term_taxonomy_id=14