【发布时间】:2021-04-07 18:37:33
【问题描述】:
我正在开发一个 WordPress 博客网站。
我正在尝试根据 WordPress 条件标签获取特定模板,如下所示:
switch(1):
case(!is_single() && get_post_type() == 'post'):
get_template_part('/frontend/template-parts/general');
break;
case(is_single() && get_post_type() == 'post'):
get_template_part('/frontend/template-parts/single/single', get_post_format());
break;
case(is_archive()):
get_template_part('/frontend/template-parts/archives/category');
break;
endswitch;
而且,它适用于前两个条件。但是,当我试图根据 is_archive() 条件标签获取位于 '/frontend/template-parts/archives/' 目录中的 category.php 模板时,这不是工作。
如何根据放置在索引中的 is_archive() 条件标记动态设置位于“/frontend/template-parts/archives/”目录中的 category.php、tag.php、archive.php、author.php 等模板.php 如上所述。
谢谢。
【问题讨论】: