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

老乐 优化维护4字数 502阅读1分40秒阅读模式

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

不过基于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。

投上你的一票
 
  • 本文由 老乐 发表于 2024年10月19日 10:18:56
  • 转载请务必保留本文链接:https://www.zhujipingjia.com/change-wpid.html
  • WordPress修改ID