Importance of Child Theme in WordPress
Hello friends. You might have heard a lot about WordPress child themes. But you won’t have much idea about what it is. In this article we are going to explain the concept of a child theme is very easy to understand way.
Using Child Themes
You might be aware that if you have customised your WordPress theme, it gets lost when the update is released and installed on the website. Now, if you want to adopt an existing theme but still want to be able to make updates to that theme without losing your work, creating a child theme will be a better approach than editing the theme itself. You would also use a child theme with a theme framework, or if you’ve developed your starter theme or framework you want to use as a basis for all projects, adding custom functionality for that site to the child theme or via plugins as required.
The Parent/Child Theme Relationship
Theoretically, any theme can be used as a parent theme, so you don’t have to limit yourself to specially designed parent themes (although some themes, including those powering theme frameworks, are designed as parent themes and wouldn’t work on their own).
The relationship between the parent and child themes can be summarized as follows:
• WordPress defaults to using template files contained in the child theme. If both themes have a version of the same template file (e.g., index.php), WordPress will use the one from the child theme.
• Where a template file is required and the child theme doesn’t have it, WordPress will use the file from the parent theme. Therefore. You wouldn’t bother creating a template file for your child theme if it were identical to that in the parent theme.
• WordPress uses the stylesheet in the child theme. In most cases, it also uses styling from the parent theme’s stylesheet, but only if you specify that in the child theme’s stylesheet—by adding the @import tag.