显示Wordpress的分层术语列表?

时间:2016-02-02 20:04:09

标签: php wordpress

我正在尝试在WP站点中输出分层术语列表(对于Jquery Istotope)。出于某种原因,它只显示顶级类别,如何按层次顺序显示所有类别?

@ActiveProfiles("local,unittest")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebAppConfiguration
@IntegrationTest
public class MyResourceTest {

1 个答案:

答案 0 :(得分:0)

get_terms函数中添加第二个参数,如下所示。

<?php
    $terms = get_terms('industry',array('parent'=>0,'orderby'=>'slug','hide_empty'=>false));
    $count = count($terms);
    echo '<li><a href="javascript:void(0)" title="" data-filter=".all" class="active">View All</a></li>';
    if ( $count > 0 ){
        foreach ( $terms as $term ) {
        $termname = strtolower($term->name);
        $termname = str_replace(' ', '-', $termname);
        echo '<li><a href="javascript:void(0)" title="" class="'.$termname.'" data-filter=".'.$termname.'">'.$term->name.'</a></li>';
        }
     }
?>