How to Create a Child Theme in WordPress

When we talk about child theme, we first have to talk about parent one. A theme become a parent only when it has a child theme. A child theme is considered the best way to customize your website. It contains all features of the parent one. You can customize it according to your need without affecting the parent one. If any update comes your theme will not affect. This is the best advantage of using them. It is the mirror reflection of the parent. Whatever changes you make to the reflection will not affect the parent. But if the parent makes any changes it will be visible in your child theme.
 

Make a child theme in WordPress

  • 1. First, open your theme directory using FTP and go to /wp-content/themes/ folder. Make a folder for your child one. We are using twenty seventeen themes so name your folder twentyseventeen-child for clarity.
     

     
  • 2. Now it’s time to make a stylesheet for the child one. Open a text editor like Notepad and paste this code:
     

     
  • 3. Now save the file as style.css inside the folder you created earlier.
     

     

    • Theme Name (required) = use the parent theme name + child to make it easy to identify (eg. ” twentyseventeen Child Theme”)
    • Description (optional)= you may enter any text here
    • Author (optional) = your name
    • Template (required) = name of the parent theme folder (in this case, it is ” twentyseventeen”)
    • Then you may add any additional custom CSS as you want in the child theme style.css (optional).

     

  • 4. Time to import stylesheet in your child folder. You can import CSS stylesheet file via two methods.
     
    First, is adding this code in the bottom of the stylesheet you created:
    @import url("../twentyseventeen/style.css");

     
    Second method is, create a text file and save this file inside the /wordpress/wp-content/themes/twentyseventeen-child folder as functions.php.
     

     
    Open the file and paste this code:
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
    function enqueue_parent_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }
  • 5. It’s time to activate your child theme. Log in to your dashboard and hover over Appearance option given in the left sidebar. Then click on Themes option.
     

     

  •  

  • 6. A new window will open and you can see your child theme is visible on the page.
     

     
  • 7. Hover on the it and you will see an Activate button. Just click on it.
     

     

  •  

  • 8. It will take few seconds and your theme will be activated. To see the changes hover over it and you will see below screenshot:
     

 
Congratulations your child theme is activated. Now you can easily customize as per your need.

Spread the love

Kapil Garg

Kapil Garg has 7 years of experience in building professional websites. He is a leading web developer, web designer and Google adwords certified partner. His passion is to designed and developed most impressive websites.

Leave a Reply

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