没有必要这样做,您需要按原样导入值。它是一个数组,只要您不以任何方式更改数据,它就可以正常工作。
无论如何,当您将 wp 站点导入迁移到另一个 URL 时,绝对不需要逐一阅读 wp-options 表的列。
你需要做的只是从 Original( old-domain
) 站点转储你的 SQL,然后导入到new-domain
,然后运行这些查询:
/**
To update WordPress options with the new blog location, use the following SQL command:
**/
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
/**
After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as abolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
**/
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
/**
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
**/
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
只是为了验证,运行这些命令后,返回选项表并验证您的 home 和 site_url 函数对于new-domain
数据都是正确的。
如果您仍然想要,出于某种晦涩的原因,手动将数据直接插入选项表中(?? 为什么),那么您应该考虑使用get_post_meta()
andupdate_post_meta()
函数来处理序列化。