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.

  • 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 Aug 25 '17 at 12:12
  • Yes, it does. WordPress created that entry anyway, so the name should be correct. – user1438038 Aug 25 '17 at 12:42
1

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.

  • This did not work for me – Eoin Nov 24 '17 at 11:41
  • This approach worked for me. I simply went to wp_options table, found the record with the field option_name set to theme_mods_parent, copied the text found in option_value to the record with the field option_name set to theme_mods_child. Of course you have to replace parent and child with the actual names of your themes. – baxeico Apr 10 at 11:09
0

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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.