How To Create WordPress Child Theme – Step By Step And Details

0
132
WordPress Child Theme
WordPress Child Theme

WordPress is the most popular content management system (CMS) or software. WordPress drive by Themes and Plugins. Themes are the main thing of WordPress. WordPress has a child-theme system. Those who work with WordPress know well how important the child theme is. Today I will discuss what the child theme is, and why I will use it.

Child Theme: It is a theme where we make our changes so that in the future, updating the original theme will not break our work. It’s work under the parent theme.

Why We Use Child Theme: The main themes of WordPress are called parent themes such as Twenty Fifteen. Now if we want to make any changes to the theme and if it is in the original theme, then updating the main theme in the future will lose all the changes. To avoid this problem we use it. So it is a theme where we all do things like – edit CSS, PHP, HTML, etc. and we can update the Parent Theme anytime.

How to use a child theme? How to install it is given below:

Step 1: To install a it, first create a folder inside WordPress theme folder. For example, if the name of our original theme is “twentyfifteen” then the theme will be named “twentyfifteen-child”. That is to say the word “-child” with the name of the original theme. The theme we are using is found in WordPress’s theme folder.

Step 2: There must be 3 files inside the theme, such as style.css, functions.php, & screenshot.png

Step 3: The code below will be in style.css. Here you will change according to your theme’s information. However, the name of “Template” must be the name of the theme. Here is- Template: twentyfifteen

[css]
/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: http://example.com
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
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/
[/css]

Step 4: The following code will be in functions.php. There will be no change in this code.

[php]
<?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’ ); } ?>
[/php]

Step 5: In the case of screenshot.png, you can use the screenshot.png image of your original theme. But for the sake of understanding, you can type the word Child Theme in the image. It is easily done with Photoshop.

Already our child-theme has been created. Now, in order to activate the child-theme, login to your WordPress site and go to Appearance > Theme and activate your child-theme. Now the child-theme is ready to use. Now do all your changes in the child theme.

Learn more about the child-theme https://codex.wordpress.org/Child_Themes

If you like the article, please share in your social media profile.

NO COMMENTS

LEAVE A REPLY