タクソノミーが持っているターム全部表示
-2015年05月26日-
[◎1]
illustrator_catの部分を表示させたいタクソノミーを書き込むだけ。
1 | <?php wp_list_categories( array ( 'title_li' => '' , 'taxonomy' => 'illustrator_cat' , 'show_count' => 1)); ?> |
★タクソノミー名を振り分けるときはこれを使う
1 | <?php $cat =(get_post_type_object(get_post_type())->name). '_cat' ; ?> |
2 | <?php wp_list_categories( array ( 'title_li' => '' , 'taxonomy' => $cat , 'show_count' => 1)); ?> |
[◎2]
illustrator_catの部分を表示させたいタクソノミーを書き込むだけ。
3 | $taxonomy = 'illustrator_cat' ; |
15 | $terms = get_terms( $taxonomy , $args ); |
17 | if ( count ( $terms ) != 0 ) { |
21 | foreach ( $terms as $term ) { |
24 | $term = sanitize_term( $term , $taxonomy ); |
25 | $term_link = get_term_link( $term , $taxonomy ); |
26 | if ( is_wp_error( $term_link ) ) { |
31 | if ( $term ->parent != 0 ) { |
32 | echo '<li class="children">' ; |
38 | echo '<a href="' . esc_url( $term_link ) . '">' . $term ->name . '</a>(' . $term -> count . ')' ; |