get_header操作不起作用

时间:2016-09-23 12:53:20

标签: wordpress wordpress-theming

我正在尝试使用get_header操作更改标题模板,但无论如何我都不会改变。

以下是我在functions.php中添加它的尝试:

function prefix_new_header() {
    return 'newtmpl';
}
add_action( 'get_header', 'prefix_new_header' );

我在主题文件夹中有一个名为 header-newtmpl.php

的文件

我尝试了不同的优先级(1,10,99),但它不起作用。

我有什么遗失的吗?谢谢你的帮助!

如果你想测试它,可以在twentysixteen中试试。

1 个答案:

答案 0 :(得分:0)

如果您已经创建了一个名为header-newtmpl.php的其他标题模板,则只需传递一个参数即可获取新标题。

来自get_header();

将其更改为get_header('newtmpl');

其中newtmpl是新标头的名称,它将获取header-newtmpl.php而不是header.php的内容

相关问题