I am trying to understand how to use a Child Theme in wordpress. I am afraid that something will go wrong in the process of developpment because I haven\'t completely understood
Think of the child theme as a layer on top of the parent theme. By default (if you add nothing to the child theme other than a style.css
file), all the templates from the parent theme will be used. The only thing you have to have is the style.css
file. If you wanted to override the page.php
template for instance, you would simply just make a page.php
file in your child directory and WordPress will use that template instead of the parent template. Same goes for any template file or template part.
You can have a functions.php file in your child theme and it will be included in addition to the parent functions file.
Usually the parent's style.css
file would be enqueued before the child's style.css
file, but it depends on how those files get enqueued. The system is quite flexible.
Your child theme is not a blank canvas. It inherits style.css, functions.php and all the post/page templates from the parent theme. The style.css file of your child theme will load after that of the parent theme, thus enabling you to add more CSS rules. The functions.php file of your child theme will load before the parent's functions.php file.
The child also inherits all the templates from the parent. However, if a template exists in the parent and you create it in the child the child theme's template will completely override the parent's template. For more information on parent-child theme relationship I highly recommend that you check the official child themes documentation.