WordPress 101

What is WordPress Child Theme?

A WordPress Child theme is essentially a theme that fully inherits the styles and functions of the parent theme. WordPress will first check to see if a template file exists in the child theme, if not, then it will pull from the parent theme. A child theme is the safest way to modify a WordPress theme without making any changes to the parent theme’s files.
 

Why You Should Use WordPress Child Theme

While many of you must be thinking why do we need to create a child theme when we have a theme where we can directly modify? The main benefit of using a child theme is that it lets you modify a parent theme. It is one of the safest and recommended way to modify a theme. Even if a parent gets updated, there will be no changes in a child theme. Another benefit of using it is while modifying child theme if the issue occurs then you can always deactivate the child theme and revert back to the parent theme.
 

How to Create a Child Theme?

  • Create a child theme folder
First, create a new folder in your themes directory, located in wp-content/themes. The directory needs a name. For example, if you were making a child theme of construction, then the directory would be named construction-child.
 
 
WordPress child theme-how to create one
 
  • Create a file titled style.css in a construction-child folder. Open the style.css, copy and paste the below code.

  • /*

    Theme Name: Construction Child                                                                                                               Template: construction

    */

     

  • Again, Create a file titled functions.php in a construction-child folder, copy and paste the below code to import the parent themes style

<?php

add_action( ‘wp_enqueue_scripts’,  ‘enqueue_child_theme_styles’, PHP_INT_MAX)                  
function enqueue_child_theme_styles(){

wp_enqueue_style( ‘parent-style ’, get_template_directory_uri(). ’ /style.css’  );                                              }   

?>

  • Now, Activate the theme

WordPress child theme-how to create one

Now simply click on the activate button to activate your child theme

Conclusion

So, creating a child theme in WordPress will allow us to safely customize a website without editing any core files. The main benefit of using a child theme is that child theme lets you modify a parent theme. 

Thank you for reading our article. We hope it gave you a certain idea about the WordPress child theme and the process to create one.