WordPress makes it really easy to customize your website and adapt its look to fit your vision. However, any modifications you make to the theme directly will be lost every time the template is updated. Here’s when a child theme comes in handy. 

It inherits the look and functionality of the parent theme and allows you to safely make any changes to your website without affecting the parent (original) theme. Customizations of parent and child themes are kept separately, so parent theme’s update won’t override the changes you’ve made to your child theme. 

You don’t really need to create a child theme to change the color of a button (this can easily be done with CSS styles in the original template). However, a child theme is a great choice if you plan to make major changes to your web store. Using a child theme is a time-saving way to make modifications to the original template without creating a new theme from scratch. 


How to create a child theme

A child theme needs three things: its own folder, a style sheet and a functions.php file.

1. Create a new folder in your themes directory 

First, you need to create a new folder in your theme directory. In your cPanel, go to File Manager => public_html => wp-content => themes and create a new folder. 

A best practice is to give a child theme the same name as the parent, but with -child added to the end. For example, a child theme of DaVinci Woo might be named davinciwoo-child

2. Create a stylesheet file named style.css

A child theme needs to include its own style.css and functions.php files which you'll use to alter styles, functions, layout, etc. When a customer visits your store, WordPress first loads the child theme, and then adds missing styles and functions from the parent theme. 

So, the next step is to create a stylesheet file named style.css. Click the + button, enter style.css as the file name, and click Create New File.

For this to work, you must add a comment about the theme to your header stylesheet. This comment must include Theme name and Template (the name of the parent theme directory).
For DaVinci Woo child theme, this code might look like this:

/*

Theme Name: DavinciWoo Child

Template: davinciwoo

*/

Right-click the style.css file you've just created to add these parameters. Save changes.


3. Add a new functions.php file

In case you plan to change your website functionality, you need to add a new functions.php file in the same folder. If you don’t plan to use PHP to modify your theme, then you can completely do without it. Just a stylesheet will be enough. 


4. Activate your child theme

Your child theme is now ready for activation. Log in to your site’s WP admin area and go to WP Dashboard => Appearance => Themes.

A couple things to keep in mind: 

  • You shouldn’t make any modifications to the parent theme files when using a child theme. Instead, copy files from the original template and add them to your child theme folder. For example, if you want to change the code of the parent theme’s header.php file, you need to copy this file to your child theme folder and customize it there. 
  • A child theme won't work without its parent theme present. 
  • There's no need to create a child theme this way in case you use the DaVinci Woo theme. You can create a child theme by pressing the Install Child button in your WP admin area => DaVinci Woo => General. 

Did this answer your question?