single.php用于分类slug


single.php for taxonomy slug

嗨,如果从我的分类法中转发了特定的"slugs",我正试图打开一个特定的single.php。

我和作者一起做了这件事

<?php $post = $wp_query->post;
if(get_the_author_meta('user_nicename', $post->post_author) == 'name') {
/* Do your author-specific work */
include(TEMPLATEPATH . '/single-coupon-1.php');
} else {
include(TEMPLATEPATH . '/single-coupon-2.php');
}
?>

但我的分类需要这个

我的分类法是

<?php echo appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'slug'); ?>

现在,如果slug是(只是一个例子)"amazon",那么应该使用singlecoupon-2.php。

我试了很多,但总是出错!现在我迷失在迷茫中;-)。。。

谢谢,任何帮助都将不胜感激!

我不确定我是否误解了你的问题,但WordPress提供了一个模板层次结构,这样你就可以为特定页面创建模板。

只需在您的主题文件中创建一个分类法-myslug.php,WordPress就会自动将其挑选出来。

如果不同模板之间存在共性,请使用get_template_part()确保只编写一次代码。