如何修改WordPress文章ID 解决新旧文章ID不同的问题

今天麦子遇到一个问题,有个朋友原来网站的程序是ZBLOG,由于他的网站数据不多就没有采用迁移转换程序的方法。如果我们需要迁移转换程序可以参考 「一篇文章记录ZBlog PHP站点数据转换WordPress迁移过程实战」,他就几篇文章就直接手动复制到新的WP站点中。

如何修改WordPress文章ID 解决新旧文章ID不同的问题

不过基于SEO的考虑和URL一致性,我建议他还是将ID进行修改到和原来网站URL一致的ID,这里我们用什么办法呢?

update wp_posts set id = 111 where id = 222;
update wp_posts set post_parent = 111 where post_parent = 222;
update wp_term_relationships set object_id = 111 where object_id = 222;
update wp_postmeta set post_id = 111 where post_id = 222;
update wp_comments set comment_post_ID = 111 where comment_post_ID = 222;

这里我们可以先进行备份数据,然后用这个办法在SQL中替换,注意111为修改后的ID,222为修改前的ID。

5/5 - (1 vote)
© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享