×
Menu
Index

Child Theme Activation

 
A child theme in WordPress is small, lightweight "add-on" theme that inherits all the styling and functionality of another theme, called the "parent theme" in this case. You can create a child theme for any theme in WordPress.
 
Child themes are used when you want to make changes to a site without actually changing the code or  files in your original theme. This lets you update your original theme (which is the engine behind the child theme) without losing any changes you made to your site.
 
In this post we’ll go over how to create a child theme and also give a rundown of 5 common scenarios for when you’d want to use a child theme.
 
Please view this video about child theme, it very useful and shows all its aspects.
Here are you can read about manual creation of child theme. Also we reproduced all these steps below:
 
1.Installing a Child Theme:
 
Our theme contains  energy.zip and energy-child.zip
 
With demo content:
Step 1b. If you need your theme filled with demo content -  choose energy.zip.
Step 2b. After demo content installation finished please upload  energy-child.zip and activate Energy Child Theme.
 
2.Overriding Parent Theme Template Files:
 
To override the template files in the parent theme, open the original template file and save a copy to the child theme folder with the same file name and folder structure. Basically, the file structure has to match with the parent theme.
 
For example:
 
For another example:
 
Here are some of the template files that you can override:
 
Child Theme functions.php (optional): if you need to add additional PHP functions, add them in the functions.php file in the child theme folder. It will load before the parent theme functions.php file.
 
<?php
 
add_action('wp_enqueue_scripts', 'energy_child_css', 100);
 
// Load CSS
function energy_child_css() {
              // energy child theme styles
              wp_deregister_style( 'energy-child-style' );
                   wp_register_style( 'energy-child-style', get_stylesheet_directory_uri() . '/style.css' );
                   wp_enqueue_style( 'energy-child-style' );
 
         if (is_rtl()) {
                  wp_deregister_style( 'energy-child-rtl' );
                  wp_register_style( 'energy-child-rtl', get_stylesheet_directory_uri() . '/rtl.css' );
                  wp_enqueue_style( 'energy-child-rtl' );
                        }
}
 
 
Changing original theme files can very easily become a cause of an issue. Child theme is a safe and easy way to change things in your main content without worries about losing your work during updating a theme. Just use a child theme.
 
Additional Child Theme Resources: