Wordpress - 显示没有链接的分类术语 - (get_terms,the_terms,wp_tag_cloud)

时间:2011-02-23 16:26:45

标签: wordpress taxonomy term

有没有办法显示Taxonomy Terms而不将它们作为链接?

我基本上想要显示“标题”分类标题下的所有条款,但没有链接。

我尝试了多种解决方案,例如get_terms,get_the_terms,the_terms,wp_tag_cloud,但我无法找到解决方案。

感谢。

3 个答案:

答案 0 :(得分:2)

bizarre 的解决方案返回了所有条款,如果您只需显示每个帖子项的条款,您可以使用此条款:

$terms = wp_get_post_terms( $post->ID, 'taxonomy-term', array("fields" => "names") );
echo implode(', ',$terms);

确保正确的“分类学术语”正确无误!

答案 1 :(得分:1)

下面的代码检索分类法的所有术语名称:

    $terms = get_terms( 'cars', array('fields'    => 'names')); 

答案 2 :(得分:0)

$terms = get_terms("taxonomy");
                 $count = count($terms);
                 if($count > 0)
                     {
                         echo '<ul>';
                         foreach ($terms as $term) 
                             {
                                 echo '<li>'.$term->name.'</li>';
                             }
                         echo '</ul>';
                     }
相关问题