WordPress Child Theme

[wp_ad_camp_1]

In this lesson, we will learn Child Theme concept in WordPress. When we talk about child theme, we first have to talk about parent theme. A theme become parent theme only when it has a child theme. A child theme is considered the best way to customize your theme. Child theme contains all features of the parent theme. You can customize your theme according to your need without affecting the parent theme. If any update comes your theme will not affect. This is the best advantage of using a child theme. A child theme is the mirror reflection of a theme. Whatever changes you make to the reflection will not affect the original or parent theme. But if the parent theme makes any changes it will be visible in your child theme. We will show how to create a child theme in WordPress.
 

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 theme. We are using twenty seventeen theme so name your folder twentyseventeen-child for clarity.
     

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

     
  • 3. Now save the file as style.css inside the child theme 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 theme 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 on 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 child theme box 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 on your child theme and you will see below screenshot:
     

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

[wp_ad_camp_3]
Spread the love