Sajid Javed

How to create a child theme

Written by sjaved
22
Jun

You are using a very nice WordPress theme that you love but there are still some aspects you need to change/enhance then what would you do. Edit the parent theme file ? No, bad idea, never ever edit the parent theme’s style.css file or any other file like functions.php file, because you will lose these changes when you will update theme.

Before going into further details lets jump to steps to create a WordPress theme. In following example I am going to create child theme of TwentySixteen theme.

Create child theme folder:

Create a new folder called twentysixteenchild in wp-content/themes folder.

Screenshot at Jun 22 17-35-26

Create child theme style.css file:

Inside twentysixteenchild folder, create a blank file called style.css file and add the following code in this file.

This is called stylesheet header that must exists in the child theme style.css file.

The most important parts of child theme header are:

  • Theme Name:
    This is the name of your child theme you can add any thing here like my first child theme.
  • Template:
    This is the parent theme folder name. In my case its twentysixteen. Make sure you replace it with your own parent theme folder/directory name.

Lastly, the following line will ensure ensure that the parent theme style.css must be loaded. In this line replace the twentysixteen with your own parent theme folder name.

@import url(“../twentysixteen/style.css”);

That is the very basic child theme to get started with CSS customization. If you want to edit other parent theme files then copy those files and paste in child theme and start editing. For example if we want to add something under logo in header then we will copy header.php file from parent folder, paste in child theme folder and start making changes.

Leave a Reply

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

Subscribe for FREE resources directly to your inbox (once or twice a month – promise).