Wordpress 使用以下表结构来存储“类别”
wp_post 通过wp_term_relationships 加入wp_terms
SELECT p.id, p.post_title, t.name FROM `wp_posts` p
join `wp_term_relationships` r on r.object_id = p.id
join `wp_terms` t on t.term_id = r.term_taxonomy_id
您需要将类别导入wp_terms 表
那么您必须将关系导入wp_term_relationships 表
所以如果你的表结构看起来像这样:
标识 | post_title | post_content |类别
1 | “我的第一篇文章” | “这是我的帖子” | “新闻”
2 | “另一个帖子” | “我的第二篇文章内容” | “文章”
你必须做一些插入
insert into `wp_terms` (name, slug) select category, category from old.posts_table;
insert into `wp_post` (
ID,
post_author,
post_date,
post_date_gmt,
post_content,
post_title,
post_excerpt,
post_status,
comment_status,
ping_status,
post_password,
post_name,
to_ping,
pinged,
post_modified,
post_modified_gmt,
post_content_filtered,
post_parent,
guid,
menu_order,
post_type,
post_mime_type,
comment_count) select -- all these values need to be populated
from old.posts_table
那么您需要根据“条款”的 id 填充关系表
希望对你有帮助