Today we will learn more about WordPress Child Themes. Why is it beneficial to create a WordPress child theme and then learn how you can create a plugin or without plugin WordPress child theme?
According to the survey of a theme selling company, 85% of the customers use their themes by customizing their themes but only 35% of them use the child theme. And the reason is that they do not know about the wordpress child theme feature.
If you do not know the WordPress Themes concept of WordPress child theme and WordPress parent theme and you also customize your theme without creating a WordPress child theme, then this post can be of great use to you.
What are WordPress Child Themes?
Just like a child is a mirror reflection of its parent and inherits things such as their looks, behavior, etc. Likewise, the WordPress child theme is called the theme that inherits the looks, functionality and code of the current theme you are using on the site. It does.
Inherits means that in a child theme you do not have to copy all the code or files of your current theme, you just have to tell which theme you are creating a child theme and then the child theme will automatically work like that theme. Seems to be.
It is very easy to create a child theme of any theme, you can create a child theme of any theme with some lines of code. Whenever you create a child theme of a theme, then we call that theme as parent theme.
Any child theme has all the features of its parent theme and apart from that the child theme can also have its own separate customize code, so if you want to customize (modify) a theme, first create its child theme.
WordPress child theme is the safest and recommended way to customize any theme as customization codes are not deleted from the child theme on the update of the parent theme and without any problem your theme also gets updated.
If you also want to make changes in the theme without coding in the files of your direct original theme (parent), then the child theme is the best solution.
Why Should You Use a Child Theme?
Most of all WordPress users add custom CSS and some other customize code to their theme by adding different files to their theme and customize it according to their choice so that their theme looks different and better than other sites.
It is also very important for a professional developer / designer because a good customize theme makes its own brand and frankly, a good theme customization takes a lot of hard work and no one will want to work so hard with an update button. It gets spoiled as soon as you click on it.
The term update is a very common term for a WordPress user because for security reasons and advanced features we all have to update the wordpress core version, our installed plugins and theme.
By updating all these, some of the code is removed from their code and some new code is added to their separate files, which causes you to show new changes (design, features etc.).
Similarly, when you update your customized theme, the code that you had added to customize the theme from all the files of that theme will be removed, and then your theme will start showing in the default style.
This means that all the customization code done after so many days and months of hard work will be removed (lost) and then you will have to re-code to customize the theme and if you want it not to happen to you. Its solution is WordPress Child Theme.
How to Create a WordPress Child Theme?
Follow all the steps which are given below to install and customize a child theme:
Step – 1: First of all you have to login to your hosting cPanel and then click on file manager and open public_html >> wp-content >> themes folder.
Now here you have to create a folder for child theme which you can give any name but I would suggest you to assign the name of “parenttheme –child” like this.
Step – 2: Now you have to open your newly created child theme folder and now in this child theme folder you have to create 2 important files: first style.css and second functions.php.
Step – 3: Now you have to select the style.css file and click on the edit button, after this assign the theme name and template name between comments / *… * / in this file.
Note: Theme name you can give anything but give the template name exactly the same name (case also) which is the name of the folder of your parent theme.
Step – 4: Now you have to select functions.php file and click on edit button and then copy-paste the code given below to enqueue (register) the parent theme’s style.css file into child theme.
add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_styles’ );
wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ );
Step – 5: Now all you have to do is login in your WordPress dashboard and go to Appearance >> Themes and activate the newly created child theme.
What Next: Now you can customize your theme by going to Appearance >> Editor and adding new custom CSS code to the style.css file of the child theme and adding new php functions to the functions.php file. And you can update the parent theme without any problem.
Benefits of WordPress Child Theme:
If you make any changes to your Parent theme, then using WordPress child themes is the safest and recommended way. You can customize it without affecting the parent theme.
This allows you to update the parent theme without losing your Changes. That is, when you update your parent theme, your customization will not be deleted.