我有多个WordPress的模板文件:WordPress模板
- 单example_1.php
- 单example_2.php
- 档案馆,example_1.php
- 档案馆,example_2 .php
这些都是完全一样的,它们只是针对不同的自定义帖子类型。正因为如此,我想将它们合并为一个。我已添加此功能:
add_filter('template_include', function($template)
{
$my_types = array('example_1', 'example_2');
$post_type = get_post_type();
if (! in_array($post_type, $my_types))
return $template;
return get_stylesheet_directory() . '/single-example.php';
});
此“重定向”每个单一和档案站点到相同的模板。
如何将归档页面仅重定向到档案示例页面和单页面示例?
非常感谢,这很好解释! –