【发布时间】:2018-01-11 10:10:24
【问题描述】:
父functions.php 中的函数需要包含。我已经编辑了这个文件的调用,但显然它仍然在父目录中。
需要 get_template_directory() 。 '/inc/widgets/team-member.php';
如何修改子functions.php中的文件url?
【问题讨论】:
父functions.php 中的函数需要包含。我已经编辑了这个文件的调用,但显然它仍然在父目录中。
需要 get_template_directory() 。 '/inc/widgets/team-member.php';
如何修改子functions.php中的文件url?
【问题讨论】:
在父主题functions.php中添加这段代码
add_action( 'wp_loaded', 'parent_prefix_load_classes', 10 );
function parent_prefix_load_classes()
{
define('MEMBER_FILE_URL', get_template_directory(). '/inc/widgets/team-member.php');
}
在智利主题中使用此代码
// Priority 11 to run after the parent theme's loader.
add_action( 'wp_loaded', 'child_prefix_create_objects', 11 );
function child_prefix_create_objects()
{
echo MEMBER_FILE_URL;
}
【讨论】:
require,而不是require_once?
get_template_directory () 仍将返回相同的父目录。我怀疑这是 OP 要求的,但老实说,我不知道 OP 要求什么。