WordPress儿童主题-一般理解 [英] WordPress Child Theme - General Understanding

查看:96
本文介绍了WordPress儿童主题-一般理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解如何在wordpress中使用儿童主题。
恐怕在开发过程中会出问题,因为我还没有完全理解如何使用子主题,或者它的集成未正确完成。
创建子主题并添加style.css和functions.php之后,我感到困惑。

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 how to use the child theme or its integration wasn't done properly. My confusion comes after I create the child theme and by adding the style.css and functions.php.

在这一点上,我可以对子主题进行任何所需的更改,并且仍然可以使用吗?

At this point, can I make any changes that I want to the child theme and it will still work?

例如,

我使用子主题修改了网站的前端后,我想添加一些表单,将数据插入到数据库。

After I modify the front-end of the website with the use of the child theme, I want to add some forms that will insert data into the database.

为了使这项工作有效,我是否必须实现父主题中的任何php文件?

还是我将孩子主题作为一个新鲜的主题(空白画布)并为后端编码,但是我希望这样做?

Do I have to implement any php files from the parent-theme in order to make this work ?
Or do I treat my child-theme as a fresh theme (blank canvas) and code the back-end however I would like ?

谢谢

推荐答案

将子主题视为父主题之上的一层。默认情况下(如果您向子主题添加除 style.css 文件之外的任何内容),将使用父主题的所有模板。您唯一要拥有的就是 style.css 文件。例如,如果要覆盖 page.php 模板,只需在其中创建一个 page.php 文件您的子目录和WordPress将使用该模板而不是父模板。任何模板文件或模板部分也是如此。

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.

您可以在子主题中包含functions.php文件,除了父函数文件以外,还将包含

You can have a functions.php file in your child theme and it will be included in addition to the parent functions file.

通常,父母的 style.css 文件将排在孩子的 style.css之前文件,但这取决于这些文件如何入队。该系统非常灵活。

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.

这篇关于WordPress儿童主题-一般理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆