Title: ktarotaroの返信 | WordPress.org 日本語

---

# ktarotaro

  [  ](https://ja.wordpress.org/support/users/ktarotaro/)

 *   [プロフィール](https://ja.wordpress.org/support/users/ktarotaro/)
 *   [作成したトピック](https://ja.wordpress.org/support/users/ktarotaro/topics/)
 *   [作成した返信](https://ja.wordpress.org/support/users/ktarotaro/replies/)
 *   [返信したトピック](https://ja.wordpress.org/support/users/ktarotaro/replied-to/)
 *   [エンゲージメント](https://ja.wordpress.org/support/users/ktarotaro/engagements/)
 *   [お気に入り](https://ja.wordpress.org/support/users/ktarotaro/favorites/)

 返信を検索

## フォーラムへの返信

1件の返信を表示中 - 1 - 1件目 (全1件中)

 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [親子関係のあるタクソノミーの一覧を表示させたい](https://ja.wordpress.org/support/topic/%e8%a6%aa%e5%ad%90%e9%96%a2%e4%bf%82%e3%81%8c%e3%81%82%e3%82%8b%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%81%a8%e7%84%a1%e3%81%84%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%81%8c%e6%b7%b7%e5%9c%a8%e3%81%97/)
 *  トピック投稿者 [ktarotaro](https://ja.wordpress.org/support/users/ktarotaro/)
 * (@ktarotaro)
 * [12年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a6%aa%e5%ad%90%e9%96%a2%e4%bf%82%e3%81%8c%e3%81%82%e3%82%8b%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%81%a8%e7%84%a1%e3%81%84%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%81%8c%e6%b7%b7%e5%9c%a8%e3%81%97/#post-175505)
 * Tsuyoshi.　様
 * ありがとうございます！
    無事にif( count( $children ) == 0 )にて希望の動作が実現
   できました。
 * 具体的には下記のようにいたしました。
 *     ```
       <?php
       $categories = get_terms('samplecat','orderby=order&order=ASC&parent=0');
       foreach ( $categories as $cat ) {
       echo '<h1>' . esc_html($cat->name) . '</h1>';
       $children = get_terms('samplecat','hierarchical=0&orderby=order&order=ASC&child_of='.$cat->term_id);
       if( count( $children ) == 0 ) {
       //タクソノミー出力
       }
       foreach ( $children as $child ) {
       echo '<h2>' . esc_html($child->name) . '</h2>';
       $catslug = $child->slug;
       $myquery = 'post_type=sample&samplecat=' . $catslug . '&showposts=-1';
       ?>
   
       <?php query_posts($myquery); ?>
       <?php if(have_posts()): while(have_posts()): the_post(); ?>
       "><?php the_title(); ?>
       <?php endwhile; endif; ?>
   
       <?php
       }
       }
       ?>
       ```
   
 * また、大変ためになるページのご紹介もいただきましてありがとうございました。

1件の返信を表示中 - 1 - 1件目 (全1件中)