我有一个主题,我为不同的模板创建了两个新文件。我现在可以在发布页面时选择这些模板:

当我转到任何子页面时,这都非常有效。我做了一个页面叫
Test
, 选择了我的一个模板,页面显示。
然而,我的挑战是,这对主页不起作用。
现在,我已将测试页设置为索引页:

然而,当我打开页面时,它并不尊重我的选择。相反,它将打开标准主题。
我想这是因为the hierachy, 但我不完全明白为什么。
有什么想法吗?:-)
最合适的回答,由SO网友:Jacob Peattie 整理而成
正如您在链接页面的层次结构流程图中所看到的,网站首页将选择front-page.php
在恢复正常页面的行为之前:

因此,如果您想为主题的首页模板创建特定模板,则需要对
front-page.php
,
或删除front-page.php
这样它的行为就像一个普通的页面。