我最近尝试从我继承的一个大型WP站点导出帖子,但遇到了同样的问题。
出于某种原因,有些术语(通过term\\u id引用)链接到其他;“父级”;“中的术语”;wp\\U term\\U分类法“;表和这些“;“父级”;“中根本不存在术语”;wp\\U术语;桌子
因此,最简单的解决方案是只需将;wp\\U term\\U分类法“;桌子
BEFORE PROCEEDING 确保您已backup 数据库的。我怎么强调都不过分。。。
然后找出带有“的冒犯性术语”;“父级”;不存在的术语:
/* For categories */
SELECT * FROM `wp_term_taxonomy` WHERE taxonomy = \'category\' AND parent NOT IN(SELECT term_id FROM `wp_terms`);
/* For tags */
SELECT * FROM `wp_term_taxonomy` WHERE taxonomy = \'post_tag\' AND parent NOT IN(SELECT term_id FROM `wp_terms`);
/* For custom terms */
SELECT * FROM `wp_term_taxonomy` WHERE taxonomy = \'some_custom_term\' AND parent NOT IN(SELECT term_id FROM `wp_terms`);
最后更新;wp“术语”分类法;相应的表格并设置“;“父级”;到0:
/* For categories */
UPDATE `wp_term_taxonomy` SET parent = 0 WHERE taxonomy = \'category\' AND parent NOT IN(SELECT term_id FROM `wp_terms`);
/* For tags (we basically "flatten" all of them to a single level) */
UPDATE `wp_term_taxonomy` SET parent = 0 WHERE taxonomy = \'post_tag\';
/* For custom terms */
UPDATE `wp_term_taxonomy` SET parent = 0 WHERE taxonomy = \'some_custom_term\' AND parent NOT IN(SELECT term_id FROM `wp_terms`);
之后,运行
wp export...
命令只会起作用。
P、 S.如果您使用的DB表前缀不是;wp\\uquot;,显然,您需要相应地更新上面的所有SQL查询