Introduction of WordPress child theme
WordPress child theme we create using parent theme. If we require any customisation on theme as per our requirement, we create a child theme.
How to create a child theme?
First step to install a WordPress. create a database for the project. After that give meaning full name of the project.
After that we can choose any theme for our project. Put wp-content under theme folder. Now set the theme for our project. Once all these steps are completed, we move further for our main part that is a child theme.
Now we create a child theme for that we will follow some steps. We copy the parent theme after that give a name for child theme here project name is intraday so child theme is same and related to the parent theme so give a meaningful name for it. I have given the name as cuda-child.
Now in a child theme which file we required only that file we will put on child theme. Only three files we will need for child theme folder.
- style.css
- functions.php
- screenshot.png
If we need to change any structure and we need for customisation of this project so we can easily do that using a child theme. If we required to change n header or footer file, we can
copy that file and pass to a child theme and now what ever changes is required in header or footer part then we make changes on child theme only no need to change parent theme.
We see here on screenshot as:
- page-fullwidth.php
- header.php
- footer.php
We create a child theme so that we require to activate a child theme. Here is a screenshot for that:
One important thing we do is that we import a style.css of parent theme on a child theme css. Like this:
@import url(“parent-theme-name/style.css”);
Create a CSS File.
Now the required things for child theme’s CSS file are:
- Theme Name
- Theme URI
- Description
- Author
- Author URI
- Template
- Version
- Tags
- Text DomainFile
When to use Child Themes?
Child themes can be used in different scenarios. We mostly use child theme to customise and modify a theme.
Advantages & Disadvantages of a Child Theme
Advantages
- We can easily customise a theme.
- All styles can be written on child theme css.
- We can do all types of changes on child theme.
- Child theme inherits parent theme style, functions file template and all features.
- We can easily update wordpress theme.
- This helps to increase the speed of development and reduces time to complete task.
- It is very flexible for customisation.
- If we forget any functionality or a code then parent theme is always available for making any correction.
- For any fallback, no need for recoding.
- Makes it Easy to Modify Popular Themes.
Disadvantage
- Disadvantage of child theme is that we require time to understand a parent theme.
Conclusion
Now a days for any wordpress project we include a child theme. It is very easy to customise. So that we can fulfill our requirement easily.