WordPress Child Theme - General Understanding

前端 未结 2 1415
有刺的猬
有刺的猬 2021-01-22 15:00

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

相关标签:
2条回答
  • 2021-01-22 15:10

    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.

    0 讨论(0)
  • 2021-01-22 15:25

    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.

    0 讨论(0)
提交回复
热议问题