如何使用子主题挂钩到父functions.php

时间:2018-01-11 10:10:24

标签: php wordpress

父函数中的函数.php需要包含。我已将此文件编辑为其调用,但显然它仍在父目录中。

需要get_template_directory()。 '/inc/widgets/team-member.php';

我如何修改子function.php中的文件网址?

1 个答案:

答案 0 :(得分:0)

在父主题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;
}
相关问题