简体   繁体   English

是否可以包含来自父主题的文件夹以供使用儿童主题?

[英]Is it possible to include folder from parent theme for child theme to use?

I have a folder in my parent theme that overrides how one plugin looks. 我的父主题中有一个文件夹,它覆盖了一个插件的外观。 If I don't copy that folder to my child theme, the look of the child theme will be different from the parent theme. 如果我不将该文件夹复制到我的子主题,则子主题的外观将与父主题不同。

Is it possible to somehow, in child theme's functions.php file, include that folder (make child theme use that folder). 有可能以某种方式,在子主题的functions.php文件中,包含该文件夹(使子主题使用该文件夹)。 I've searched all over but didn't find anything. 我搜遍了所有但没有找到任何东西。

The only way to make the child theme looks like the parent (that I can then modify) is to copy that folder in the child theme folder. 使子主题看起来像父(我可以修改)的唯一方法是将该文件夹复制到子主题文件夹中。

I tried with 我试过了

$theme_folder = scandir(get_template_directory_uri().'/folder');

But I get the following warnings 但我收到以下警告

Warning: scandir(...): failed to open dir: not implemented in \functions.php on line 20

Warning: scandir(): (errno 9): Bad file descriptor in \functions.php on line 20

And I've read that that may be because of lack of permissions on the server. 我读过这可能是因为服务器上缺少权限。

复制子文件夹中的父文件夹。

if it were a styling problem, Wordpress good practices said that styles should be added by enqueuing. 如果它是一个造型问题,Wordpress良好实践说应该通过排队添加样式。

https://codex.wordpress.org/Function_Reference/wp_enqueue_style https://codex.wordpress.org/Function_Reference/wp_enqueue_style

You should try to confirm if your theme really do in that way and if your child theme does too. 您应该尝试确认您的主题是否真的以这种方式进行,以及您的子主题是否也是如此。

If your theme is overriding php template files, you just copy that folder to your child theme, edit what you want and delete unedited files. 如果您的主题覆盖了php模板文件,您只需将该文件夹复制到您的子主题,编辑您想要的内容并删除未编辑的文件。

Anyway I recommend to check theme documentation or ask support. 无论如何,我建议检查主题文档或询问支持。 Most themes have a child theme file to download or instructions to do as theme developers likes. 大多数主题都有一个要下载的子主题文件或者主题开发人员喜欢的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM