Menu Close

WordPress Tutorial – Importing Customizer setting from parent to child theme

In this article, we look at how to import your parent theme’s customizations to your child theme. If you created a child theme before you started playing around with the (parent) theme files, then there is nothing much for you here. But if you started off as a WordPress noob (like me), tweaking the parent theme (css and php files) only to realize that all of it is lost when you update the theme, then this article might help you.

Pre-requisite

  • You have a WordPress site with a theme.
  • Have created a child theme for your parent theme.
  • You have imported the style.css and optionally the functions.php file from your parent theme to your child theme.
  • But your child theme still looks a little different from your parent theme. The reason being that importing style.css does not import the customizations that you have done to your parent theme.

What are customizations?

In your WordPress menu (on the left), if you go to Appearance -> Customize, it shows up a bunch of customizations like the setting the header, footer, site layout, typography etc. These are the customizations that do not get imported to your child theme, and that is the reason why your child theme might look slightly different from you parent theme.

Copying the customizations directly in database

WordPress stores a lot of your website data in MySql database. This includes you page/post content, site metadata, and of course the customization options. Let’s look at how you can copy the customizations from your parent theme to child theme:

Login to phpMyAdmin

The first step is to login to you phpMyAdmin. Most hosting providers use phpMyAdmin to manage MySql databases. I have added links to a couple of the hosting providers: Godaddy, Bluehost.

Accessing your wordpress database

The left side of phpMyAdmin shows a list of databases. Open your WordPress database. It is either named wordpress or might start with wp_. Inside your wordpress database, go to wp_options table.

Copy parent theme options

In your wp_options table, search for the option_name theme_mods_<theme_name>. Where <theme_name> is the name of your theme. In my case, i use customify theme, the option_name would be theme_mods_customify. You can either search the table manually (there are about 10 pages!) or you can use the below sql query to search those entries easily:

SELECT * FROM ‘wp_options’ WHERE option_name LIKE ‘theme_mods_%’

This will list all the entries in the table with the option_name starting with theme_mods_.

Copy parent options into child options

The last step is to copy the options from your parent to your child. In the image below, you see 4 rows, one for each theme that I have. The first row is the parent theme customify and the second row is the child theme that i created, customify-child. Copy the contents of your parent theme by clicking on the copy option. Paste it in your child theme value, by clicking on edit.

Refresh you wordpress website (with child theme) and you should be able to see all the customizations from your parent theme imported into your child theme. If it hasn’t, it’s probably because you messed up while copying. Try copying using a sql query, instead of manually doing it. The sql query would look something like this, but you can always google it:

UPDATE ‘wp_options’ SET option_value = (SELECT option_value WHERE option_id = 25) WHERE option_id = 26

Here, 25 is the option_id of theme_mods_customify and 26 is the option_id of theme_mods_customify-child .

If you have any questions, leave it in the comments below. Happy blogging!

Leave a Reply

Your email address will not be published. Required fields are marked *