Create a Child Theme


If you’re customizing a WordPress theme, it’s best to create a child theme . With a child theme, you can update the parent theme when updates are available. Any customizations you make to the child theme will be retained.

Here’s what we need to do.

1. Create a new theme folder (with your child theme name) and upload it to wp-content/themes.

2. Let’s place a style.css file inside that folder. It should look like this:

/* Theme Name: Merchant Child Author: PixelGrapes Template: merchant Version: 1.0.0 License: GNU General Public License v2 or later */ 

4. In the Template field, change ‘merchant’ to your parent theme. This field is the only really significant field up there.

5. Change the Theme Name and any other details you want.

6. Now let’s create one more file called functions.php and place the following inside:

<?php function pg_custom_enqueue_child_theme_styles() { wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'pg_custom_enqueue_child_theme_styles' ); 

7. Zip up the folder and install it as a theme. Activate your child theme by going to Appearance > Themes and select the Child theme. If you want a screenshot there as other themes display, add a screenshot.png file to your child theme folder.

Now any changes you make to your child theme’s stylesheet will overwrite the parent theme’s styles. Additionally, any files you add, such as page.php or single.php, will overwrite the parent theme’s files. The functions.php file information will be added to the parent’s functions.php file rather than overwriting it.

Note: In WordPress you can go to appearance/editor to make changes to your child theme files.

When the parent theme gets updated, just apply the update to the parent folder and your child theme’s customizations will remain intact.

Good stuff!


Still need help? Get Support Get Support