我使用表wp_posts将旧数据库中的文章引入到新的WordPress数据库中,但是我不知道如何指明每篇文章属于哪个部分。它有5个不同的部分,从旧的数据库我知道哪篇文章在哪个部分。
发布于 2017-08-04 00:45:15
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表中
因此,如果您的表结构如下所示:
类别id| 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然后,您将需要根据"terms“的ids填充关系表。
希望这能有所帮助
https://stackoverflow.com/questions/45463784
复制相似问题