为什么不使用元字段?这样,您就可以确定要用于特定类别模板的模板。
在循环中,只需获取要加载的当前类别:
if( have_posts() ) {
while( have_posts() ) {
the_post();
$meta_value = get_post_meta( get_the_ID() , \'meta-field\', true );
if($meta_value == \'template1\') {
//I prefer using this method. Create folder templates with file content-template1.php where you can design your content. That way it is way more clear.
get_template_part(\'templates/content\',\'template1\');
// or you can use this method
the_title();
}
}
// Very Important
wp_reset_postdata();
}