有时我们需要将一个网站搬迁到另一个服务器。我们只想保留网站的模板样式,而不需要文章内容。一般情况下我们可以在后台删除已发表的文章,但如果有很多文章,我们则需要一次删除所有文章。
WordPress如何批量删除所有文章
进入phpMyAdmin数据库管理,在SQL框中,执行SQL语句。
DELETE FROM wp_posts WHERE ID >= 1;
DELETE FROM wp_postmeta WHERE meta_id >= 1;
WordPress批量删除所有文章和分类
如果想一次性全部清空所有文章和分类,可以使用以下的语句:
DELETE FROM wp_posts WHERE ID >= 1;
DELETE FROM wp_postmeta WHERE meta_id >= 1;
DELETE FROM wp_term_relationships WHERE object_id >= 1;
DELETE FROM wp_term_taxonomy WHERE term_id >= 1;
DELETE FROM wp_terms WHERE term_id >= 1;
DELETE FROM wp_termmeta WHERE meta_id >= 1;
清空回收站语句SQL
DELETE FROM wp_posts WHERE post_status="trash";
清空草稿语句SQL
DELETE FROM wp_posts WHERE post_status="draft";