如何获取当前的自定义帖子类型相关分类术语

时间:2015-03-10 23:43:19

标签: wordpress wordpress-plugin wordpress-theming

我有一个single.php文件,如下所示

<?php get_header(); ?>
<?php 
if ( have_posts() ) {
    while ( have_posts() ) {
        the_post(); 
            echo '<div">';
               the_content();
            echo '</div>';
    } // end while
} // end if
?>
<?php get_footer(); ?>

现在我需要将当前自定义帖子类型相关分类术语作为链接放在页面顶部,这样如果用户点击该链接,页面就会导航到taxonomy.php。

你能告诉我怎么做吗?

由于

1 个答案:

答案 0 :(得分:1)

您可以在循环中使用 get_the_term_list 来获取相关的分类术语链接:

global $post
$terms = get_the_term_list($post->ID, 'your_taxonomy'); 
echo $terms;

这对我来说是一个很好的解决方案,因为我只有一个与每个帖子相关的分类术语。

相关问题