最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

database - Copy customizer options to child theme

programmeradmin3浏览0评论

I am using the OceanWP theme and customized it with the WordPress Customizer feature. Then, I created a child theme based on OceanWP, because I introducted some new shortcodes and did not want to alter the base theme. Unfortunately, when I switch themes, all my customization is lost.

I know that the customization is stored in the WordPress options table. I found theme_mods_ocean and copied the content to theme_mods_myChildTheme. I can store the changes, but as soon as I reload the blog, the database entry is reverted to its initial value.

How is this possible? Is there any other place where the customization is saved and restored from? I do not want to re-configure the entire child theme, if possible.

I am using the OceanWP theme and customized it with the WordPress Customizer feature. Then, I created a child theme based on OceanWP, because I introducted some new shortcodes and did not want to alter the base theme. Unfortunately, when I switch themes, all my customization is lost.

I know that the customization is stored in the WordPress options table. I found theme_mods_ocean and copied the content to theme_mods_myChildTheme. I can store the changes, but as soon as I reload the blog, the database entry is reverted to its initial value.

How is this possible? Is there any other place where the customization is saved and restored from? I do not want to re-configure the entire child theme, if possible.

Share Improve this question asked Aug 25, 2017 at 12:09 user1438038user1438038 1761 silver badge12 bronze badges 3
  • WordPress doesn't store theme mods anywhere else, but can't be sure that your parent theme doesn't. Does myChildTheme, where you've copied the database row, match the folder name of your child theme exactly? – Jacob Peattie Commented Aug 25, 2017 at 12:12
  • Yes, it does. WordPress created that entry anyway, so the name should be correct. – user1438038 Commented Aug 25, 2017 at 12:42
  • 1 Does this answer your question? Preserving theme settings in child theme – Melebius Commented Apr 16, 2021 at 8:22
Add a comment  | 

3 Answers 3

Reset to default 2

Definitely backup your database FIRST before trying this out.

I just tested changing the option_name of a set of customizer changes to match a different theme, and it appears we can make the customizer changes switch to another theme simply by changing the option_name to match our new theme, instead of copying the option_value serialized data over. I didn't have a child theme handy to test this, but the premise is the same.

First, using your favourite DB editor find the option for theme_mods_myChildTheme in your options table, and change the option_name to something like theme_mods_myChildTheme-backup, then you can easily switch back to this if you need to.

Next find the option for theme_mods_ocean, and edit the option_name to be theme_mods_myChildTheme.

Finally go visit the Appearance >> Customize page in your child theme, and you should see all the customizer option values from your parent theme are set there now. Keep in mind this means these values are no longer set for your other theme.

I was able to export and import the Customizer settings using this Plugin : Customizer Export/Import (Version 0.9.1 | By The Beaver Builder Team). https://en-ca.wordpress/plugins/customizer-export-import/

It works like a charm and is safer than the database manipulation method.

This is the weak point of Customizer vs Child Themes. All Customizers options are stored in the db and they are meant to be used with the original theme. If you switch to another theme (i.e. your child theme), the options remain bound to the original one.

As an option, you should deeply study the content of your options table theme_mods for the original theme, an try to "translate" them into your child style.css (whenever possible.)

发布评论

评论列表(0)

  1. 暂无评论