James Stanley

How to copy Wordpress theme customisations to a child theme

Mon 23 May 2016
Tagged: software

I've been working with Wordpress a little lately. I learnt that you're supposed to create a child theme in order to make modifications to it, but I'd already modified the theme settings (colours, etc.) using the Wordpress 'Customise' tool and couldn't see how to copy these settings to the child theme.

I tried to Google for how to do this, but the best I found was:

You could migrate those settings, but doing so involves direct manipulation of your SQL database.

I thought "yes, I know that, tell me how to do it". So this is that.

There is a row in the wp_options table with option_name='theme_mods_themename', for a theme called themename. All we need to do is copy this row, with option_name='theme_mods_themename-child' for our child theme called themename-child.

Run this at the MySQL prompt (edit themename and themename-child appropriately, of course):

INSERT INTO wp_options (option_name, option_value, autoload) SELECT 'theme_mods_themename-child', option_value, autoload FROM wp_options WHERE option_name='theme_mods_themename';

Then do a 'Live preview' to make sure it worked.

If you like my blog, please consider subscribing to the RSS feed or the mailing list: