×
Saturday, August 18
Home/WordPress Resources/WordPress Child Theme

Most of the people would like to customize their theme to make some minor changes or to add some functionality to the theme. To start ahead and dive deep into customization we recommend to read this article and get some knowledge about child theme.

What is child theme?

Basically child theme is just a small theme file which needs just two files (style.css and functions.php) to run and imports styles and functions from another (Parent ) theme.

Why Child Theme?

If you would like to make modification to the current theme then creating child theme is best way to start. If you create child theme this will not damage your main theme and if something wrong goes you can always rollback and also if latter there is update available of the theme you can update your theme without any doubt.

Lets Start Creating Child Theme

  • Create a folder and name it something like ‘twentyfifteen-child’
  • inside the folder create a file named ‘style.css‘ and paste following codes
/*
 Theme Name:   Twenty Fifteen Child
 Description:  Twenty Fifteen Child Theme
 Template:     twentyfifteen
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Text Domain:  twenty-fifteen-child
*/
  • Now create another file and name this as ‘functions.php‘ and copy and paste following codes
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}
?>

 

Your child theme is ready but make sure to replace ‘Template’  in style.css with the name of the parent theme folder.

If you are getting trouble in creating child theme then there are plugins available on wordpress.org for this you can also use the plugin “One Click Child Theme