【问题标题】:WP Customizer theme settings disapearing after wp database restore/migrateWP Customizer 主题设置在 wp 数据库还原/迁移后消失
【发布时间】:2019-12-06 21:29:32
【问题描述】:

我正在尝试使用定制器定制的主题迁移现有的 wordpress。 我可以启动并运行 wordpress,但所有的主题定制都消失了。我将问题缩小到数据库中的定制器和 wp-options 表。每当我访问/重新加载网站时,选项 theme_mods_{theme-name} 的 option_value 就会被重置。如果我通过定制器进行更改,它们确实会出现,但如果我更改数据库中 option_value 的值,则会删除整个主题定制。

我使用的是托管在 IIS 上的 wordpress,数据库是 MySql 5.x(不知道确切的版本)。

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    好的,我遇到这个问题有一段时间了,终于解决了。这个anwser让我走上了正轨:Showing default theme when uploading WordPress website on server

    迁移时,您可能使用查找和替换通过 SQL 文件更改了 URL。问题是 wp_options 表中的 theme_mods_{theme-name} 条目被编码为具有这种格式的对象:type:length:value 所以,改变一个选项的值,你也可能改变他的长度。如果长度与值不匹配,WP 将认为此对象无效并将选项重置为默认的a:1:{s:18:"custom_css_post_id";i:-1;},从而破坏您的菜单和其他自定义选项。

    示例:

    在本地主机上工作:

    a:4:{s:18:"custom_css_post_id";i:-1;s:18:"nav_menu_locations";a:5:{s:6:"menu-1";i:1120;s: 6:"menu-2";i:1125;s:8:"顶部菜单";i:1120;s:8:"footer-1";i:1120;s:8:"footer-2"; i:1125;}s:9:"my_option";s:29:"Lorem ipsum";s:15:"posts_row_image";s:32:"http://localhost/lorem/dolor.png";}

    在远程服务器上无效:

    a:4:{s:18:"custom_css_post_id";i:-1;s:18:"nav_menu_locations";a:5:{s:6:"menu-1";i:1120;s: 6:"menu-2";i:1125;s:8:"顶部菜单";i:1120;s:8:"footer-1";i:1120;s:8:"footer-2"; i:1125;}s:9:"my_option";s:29:"Lorem ipsum";s:15:"posts_row_image";s:32:"http://mydistantwebsite.com/lorem/dolor.png";}

    更正长度,在远程服务器上工作:

    a:4:{s:18:"custom_css_post_id";i:-1;s:18:"nav_menu_locations";a:5:{s:6:"menu-1";i:1120;s: 6:"menu-2";i:1125;s:8:"顶部菜单";i:1120;s:8:"footer-1";i:1120;s:8:"footer-2"; i:1125;}s:9:"my_option";s:29:"Lorem ipsum";s:15:"posts_row_image";s:43:"http://mydistantwebsite.com/lorem/dolor.png";}

    【讨论】:

      猜你喜欢
      • 2018-03-28
      • 2020-07-25
      • 2017-06-28
      • 2018-06-02
      • 2015-12-07
      • 2018-06-25
      • 1970-01-01
      • 2015-06-30
      • 2016-10-22
      相关资源
      最近更新 更多