Here we will learn about creating a child theme in WordPress.
A child theme is the best way to customize your WordPress theme. Child Theme inherits the look & feel of Parent Theme and All functions. you can customize its code without affecting the original functionality.

Benefits of Child Theme:

  • Make your changes portable & replicable.
  • If you will update parent theme your changes not lose.
  • Just disable the child theme, If you are not satisfied with your customization everything will be as it was before.

Here is a step to create a child theme:

  1. First need to create a new folder in this directory /wp-content/themes/ and give folder name same as the parent name only add “-child” at the end. like this “twentyseventeen-child”.

2.  In child folder create a stylesheet style.css

3. Inside style.css add below code:

/*
Theme Name:  Twenty seventeen Child
Theme URI:   http://example.com/twenty-seventeen-child/
Description: Twenty seventeen Child Theme
Author:      thecodehubs
Author URI:  http://example.com
Template:    twentyseventeen
Version:     1.0.0
License:     GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags:        light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twentyseventeenchild
*/

The following information is required:

Theme Name – Needs to be unique to your theme.
Template – Name of the parent theme directory.

4. In child folder create a functions.php

5. put this code in function file:

<?php
function thecodehubs_enqueue_script_style() {
     wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array(), '1.0.0', 'all');
}
add_action( 'wp_enqueue_scripts', 'thecodehubs_enqueue_script_style' );
?>

6. To set the image of the child theme copy “screenshot” image from the parent theme’s folder and put this “screenshot” in the child theme’s folder.

7.  Your child theme is now ready for activation. Log in to your site’s Administration Screen, and go to Administration Screen > Appearance > Themes. You should see your child theme listed, To activate the child theme click on the Activate button.

 

Learn More about how to enqueue style and script from our article How To Enqueue Css And Js File Using WordPress

Footer Logo

Subscribe

Select Categories