WordPress儿童主题包括包括文件 [英] WordPress Child Theme including includes files

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

问题描述

我正在使用AMPPS作为我的本地主机在我的本地计算机上进行 WordPress 设置。使用Delta主题我创建了一个子主题(delta2-child)。初始设置工作伟大。但是,我需要更改名为home-slider.php的includes文件夹中的文件。

I am working at a WordPress setup on my local computer using AMPPS as my localhost. Using the Delta Theme I created a Child Theme (delta2-child). The initial setup works great. However, I need to change a file in the includes folder called home-slider.php.

原始档案的位置:

c:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta\includes\home-slider.php

子主题文件的位置:

c:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta2-child\includes\home-slider.php

如果我将主滑块文件移动到子主题文件夹[delta2-child\includes\home-slider.php],主题仍然使用父主题home-

If I move the home-slider file to the Child Theme folder[ delta2-child\includes\home-slider.php ], the theme still uses the Parent Themes home-slider file.

如果我将以下内容添加到CT的functions.php文件中:

If I add the following to the CT's functions.php file:

require_once( get_stylesheet_directory_uri() . "/includes/home-slider.php" ); */

我得到以下错误:

Warning: require_once(C:\Program Files (x86)\Ampps\www\armstrong/wp-content/themes/delta/includes/home-slider.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta2-child\header.php on line 87

Fatal error: require_once() [function.require]: Failed opening required 'C:\Program Files (x86)\Ampps\www\armstrong/wp-content/themes/delta/includes/home-slider.php' (include_path='.;C:\php\pear') in C:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta2-child\header.php on line 87

任何知识渊博的灵魂告诉我如何引用home-slider文件,而不用改变上面的错误。

Can any knowledgeable soul tell me how to refer to the home-slider file without gernerating the error above.

推荐答案

请使用 get_template_part 功能

更改 p>

Change

require_once( get_stylesheet_directory_uri() . "/includes/home-slider.php" );

get_template_part(includes/home-slider);

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

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