显示特定帖子类型的所有分类

时间:2013-02-19 11:41:52

标签: wordpress taxonomy custom-taxonomy

在一个wordpress项目中,我创建了一个名为“product”的帖子类型,并注册了名为“product_category”的物流,这是一个物流的。我在管理面板中添加了四个类别,分别是“烤箱”,“尼特”,“纺织品”,“服装”。在每个下面我添加了两个更多的taxnomies称为'裤子','衬衫',再次这两个中的每一个我想添加更多三个类别命名为'男人','女人','孩子'......最重要的结构我预期是,

烤箱

-Pant

 -Man
 -Woman
 -children

-shirt

 -Man
 -Woman
 -children

尼特

-Pant

 -Man
 -Woman
 -children

-shirt

 -Man
 -Woman
 -children

纺织

- >裤

 ->Man
 ->Woman
 ->children

- >衬衫

 ->Man
 ->Woman
 ->children

穿戴

- >裤

 ->Man
 ->Woman
 ->children

- >衬衫

 ->Man
 ->Woman
 ->children

在前端我想展示这些就像上面的结构一样,我怎样才能显示这样的分类法,以便点击最后一级分类,将显示相关的帖子,为此我应如何制作分类法? 谢谢。

1 个答案:

答案 0 :(得分:1)

您需要编辑主题文件。例如,如果您使用“二十二”主题,请在行“<div class="entry-content">

之后添加”content.php“
<ul class="entry-taxonomies">
  <?php // taxonomies
  $id = get_the_ID();
  foreach ( get_object_taxonomies( 'post' ) as $taxonomy ) {
    $terms_list = get_the_term_list( $id, $taxonomy, '<ul class="tax-terms"><li>', '<span class="tax-sep">'.__( ', ', 'twentytwelve' ).'</span></li><li>','</li></ul>' );
    if ( $terms_list ) {?>                  
     <li><span class="tax-taxonomy"><?php echo $taxonomy; ?></span><?php echo $terms_list; ?></li><?php
    }
  }?>
  </ul>

更多信息:http://wp.tutsplus.com/tutorials/plugins/a-guide-to-wordpress-custom-post-types-taxonomies-admin-columns-filters-and-archives/

希望这会有所帮助。 乙

相关问题