我似乎无法让wc_get_template()
返回我的页面模板。我确定路径在我的子主题文件夹中存储的位置是正确的,但运行时我得到了NULL
。你能看出这里有什么问题吗?
public function endpoint_content() {
// The template name.
$template_name = 'Students Details';
// (default: array())
$args = array();
// The template path.
$template_path = get_stylesheet_directory().'/woocommerce/myaccount/add_students.php';
// NOTICE! Understand what this does before running.
$res = wc_get_template($template_name, $args, $template_path, $template_path);
var_dump($res);
}
wc_get_template()
函数的代码,它不会返回任何东西。在其他文档中,它指定了“返回:void”。 - Henderswc_get_template_html()
,它是“...类似于wc_get_template,但返回HTML而不是输出它”。 - Henders