サイドバーに各カスタム投稿タイプで使用されているタームのみを表示しているのですが、
全てのカスタム投稿タイプで使用しているタームi一覧をトップページに表示する必要があり、その方法を探しています。
各カスタム投稿タイプはCustom Post Type UI、固定ページを使用して表示させています。
ご教授いただけますと幸いです。よろしくお願い致します。
<?php if (is_tax('hoge1_tag') or is_page(array(201))){ $taxonomies = 'hoge1_tag'; } elseif (is_tax('hoge2_tag') or is_page(array(208))){ $taxonomies = 'hoge2_tag'; } elseif (is_tax('hoge3_tag') or is_page(array(217))){ $taxonomies = 'hoge3_tag'; } $args = array( 'parent' => 0, ); $parent_categories = get_terms( $taxonomies, $args ); foreach ( $parent_categories as $parent_category ) { echo '<li><a href="' . esc_url( get_term_link( $parent_category->term_id, $taxonomies )) . '">' . $parent_category->name . '</a></li>'; $args = array( 'parent' => $parent_category->term_id, ); $child_categories = get_terms( $taxonomies, $args ); if ( $child_categories ) { echo '<ul class="children">'; foreach ( $child_categories as $child_category ) { echo '<li><a href="' . esc_url( get_term_link( $child_category->term_id, $taxonomies )) . '">' . $child_category->name . '</a></li>'; } echo '</ul>'; } } ?>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/03 10:10
2018/02/03 10:24