【问题标题】:Wordpress - Display Taxonomy Terms without Links - (get_terms, the_terms, wp_tag_cloud)Wordpress - 显示没有链接的分类术语 - (get_terms, the_terms, wp_tag_cloud)
【发布时间】:2011-02-23 16:26:44
【问题描述】:

有没有办法在没有链接的情况下显示分类术语?

我基本上想在“标题”分类下显示所有术语,但它们不是链接。

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

谢谢。

【问题讨论】:

    标签: wordpress taxonomy breadcrumbs


    【解决方案1】:

    bizarre的解决方案返回了所有的terms,如果你只需要显示每个post item的terms你可以使用这个:

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

    确保正确的“分类术语”正确!

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:
        $terms = get_terms("taxonomy");
                         $count = count($terms);
                         if($count > 0)
                             {
                                 echo '<ul>';
                                 foreach ($terms as $term) 
                                     {
                                         echo '<li>'.$term->name.'</li>';
                                     }
                                 echo '</ul>';
                             }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-10-12
          • 1970-01-01
          • 1970-01-01
          • 2022-01-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-01-16
          相关资源
          最近更新 更多