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

---

# iguigu

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

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

 返信を検索

## フォーラムへの返信

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

1 [2](https://ja.wordpress.org/support/users/iguigu/replies/page/2/?output_format=md)
[3](https://ja.wordpress.org/support/users/iguigu/replies/page/3/?output_format=md)
[→](https://ja.wordpress.org/support/users/iguigu/replies/page/2/?output_format=md)

 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [jquery autopager 1ページ目が読み込まれる](https://ja.wordpress.org/support/topic/jquery-autopager-1%e3%83%9a%e3%83%bc%e3%82%b8%e7%9b%ae%e3%81%8c%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%be%e3%82%8c%e3%82%8b/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/jquery-autopager-1%e3%83%9a%e3%83%bc%e3%82%b8%e7%9b%ae%e3%81%8c%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%be%e3%82%8c%e3%82%8b/#post-226333)
 * リンク先は page2 になっていますが、
    押すと読み込まれるのは1ページ目の記事です。
   何回クリックしてもそうなります、
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/page/2/#post-226105)
 * whileの外側に置いたら直りました！
 * タクソノミーの勉強になりました！
    本当にありがとうございました！
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/page/2/#post-226103)
 * 階層構造の理解が乏しかったです。
 * ありがとうございます。
    あともう１点だけ教えてください。
 *     ```
       $i=0;
   
       $i++;
       ```
   
 * 上記のコードでランキングの順位を出しているのですが、
    階層でループした時に、 
   1 2 1 2 3と順位の表示がなってしまいました。 1 2 3 4 5となるにはどうしたらいい
   でしょうか？
 *     ```
         $posts = get_posts( $args );
         $i = 0;
         foreach ( $posts as $post ):
         $i++;
           setup_postdata( $post );
           //
           // ランキングされた投稿を表示
           //
       ```
   
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/page/2/#post-226101)
 * なるほど、
    例えばある記事は、下記の様な階層構造のタームです。 一番下の階層のみ
   にチェックが付いている場合は、 たしかに意図した表示になりました。 全部にチェック
   を入れると、階層構造でも全部対象となってしまうということでしょうか？
 * 美容整形・美容皮膚科コラム
    -身体の整形・ダイエット・ボディメイキング 　–豊胸・
   バスト
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-226099)
 * 失礼いたしました。
    タームです。
 * 例で言いますと、
    [https://call-to-beauty.com/column_category/bust/](https://call-to-beauty.com/column_category/bust/)
 * こちらのタームには記事が5つ以上あるので、
    この中の記事詳細に行った時に表示さ
   れるランキングはこのタームの中のPV上位５つになるはず、 というイメージです。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-226094)
 * 現在このようになっています
 *     ```
          <ul class="list-ranking">
       	  <?php
   
       $postid = get_the_ID();  // 現在の投稿のID
       $posttype = get_post_type();  // 現在の投稿の投稿タイプ
       $mytax = 'column_category';  // タクソノミー
   
       // 現在の投稿のターム(の配列)
       $ids = array();
       $terms = get_the_terms( $postid, $mytax );  // タームのオブジェクトの配列
       if ( ! is_wp_error( $terms ) && $terms ) {  // 投稿にタームがついている時だけ
         foreach ( $terms as $term ) {
           $ids[] = $term->term_id;  // タームIDの配列を作る
         }
       }
       $to_show = 5;  // あと5つ表示したら終わり
       while ( $to_show > 0 ):
         if ( empty ( $ids ) ) {
           break;  // 投稿にタームがないので表示終わり
         }
   
         // 同じタームを持つ投稿(現在の投稿を除く)を取得
         $args = array(
           'posts_per_page' => $to_show,
           'post_type' => $posttype,
           'meta_key' => 'views',
           'orderby' => 'meta_value_num',
           'tax_query' => array( array(
             'taxonomy' => $mytax,
             'terms' => $ids,
             'include_children' => false,  // タームの現階層のみ
             // 親タームの投稿の方がランキングが高くても子タームの方が優先される
           )),
           'post__not_in' => array( $postid )  // 現在の投稿を除く
         );
         $posts = get_posts( $args );
         $i = 0;
         foreach ( $posts as $post ):
         $i++;
           setup_postdata( $post );
           //
           // ランキングされた投稿を表示
           //
   
   
           ?>
   
       <li class="media kanshu">
         <!-- ランキング順位 -->
         <div class="rank"><?php echo $i; ?></div>
         <!-- サムネイル -->
         <div class="media-left">
         <a href="<?php the_permalink() ?>"><?php the_post_thumbnail( 'thumb' ); ?></a>
         </div>
         <!-- 記事 -->
         <div class="media-body">
         <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
         </div>
       </li>	                  
   
   
       <?php
         endforeach;
         wp_reset_postdata();
   
         $to_show -= count( $posts );  // 表示した分を減らす
         // 先祖タームを取得
         // 現在の投稿に2つ以上タームがある場合、最初のタームに絞って先祖を取得
         $ancestors = get_ancestors( reset( $ids ), $mytax, 'taxonomy' );
         if ( count( $ancestors ) < 2 ) {
           break;  // 親タームがないので表示終わり
         }
         $ids = array( $ancestors[1] );  // 親タームを次の対象にする
       endwhile;       
       ?>
       <?php wp_reset_query(); ?>
   
       </ul>
       ```
   
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-226093)
 * ありがとうございます。
 * 入れてみたのですが、変わらないですね。。
    表示中の記事はランキングに出てこない
   ようにはなっています。
 * [https://call-to-beauty.com/column_category/bust/](https://call-to-beauty.com/column_category/bust/)
 * 右カテゴリの人気ランキングがそうですが、
    取得されるランキングはつねにカテゴリ
   全体の中のものになってます。。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 6ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-226074)
 * ありがとうございます。
 * しかし、自分の間違いを見つけることができません、、、
    いきなり前回カテゴリから
   取得して来てるようです。。。＞＜
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-225969)
 * 入れてみたのですが、
    結果は一番親の階層からしか取得してきてないようです。
 * [https://call-to-beauty.com/column/c423/](https://call-to-beauty.com/column/c423/)
 * もしかしてforeachの中の書き方が悪いのでしょうか？？？
 *     ```
         <ul class="list-ranking">
       	  <?php
   
       $postid = get_the_ID();  // 現在の投稿のID
       $posttype = get_post_type();  // 現在の投稿の投稿タイプ
       $mytax = 'column_category';  // タクソノミー
   
       // 現在の投稿のターム(の配列)
       $ids = wp_get_post_terms( $postid, $mytax, array( 'fields' => 'ids' ) );
       $to_show = 5;  // あと5つ表示したら終わり
       while ( $to_show > 0 ):
         if ( empty ( $ids ) ) {
           break;  // 投稿にタームがないので表示終わり
         }
   
         // 同じタームを持つ投稿(現在の投稿を除く)を取得
         $args = array(
           'posts_per_page' => $to_show,
           'post_type' => $posttype,
           'meta_key' => 'views',
           'orderby' => 'meta_value_num',
           'tax_query' => array( array(
             'taxonomy' => $mytax,
             'terms' => $ids,
             'include_children' => false,  // タームの現階層のみ
             // 親タームの投稿の方がランキングが高くても子タームの方が優先される
           )),
           'post__not_in' => array( $postid )  // 現在の投稿を除く
         );
         $posts = get_posts( $args );
         foreach ( $posts as $post ):
           setup_postdata( $post );
           //
           // ランキングされた投稿を表示
           //
   
   
           ?>
   
       	            <li class="media kanshu">
       	                  <!-- ランキング順位 -->
       	                  <div class="rank"><?php echo $i;?></div>
       	                  <!-- サムネイル -->
       	                  <div class="media-left">
       	                    <a href="<?php the_permalink($posts->ID) ?>"><?php the_post_thumbnail($posts->ID,'thumb'); ?></a>
       	                  </div>
       	                  <!-- 記事 -->
       	                  <div class="media-body">
       	                    <a href="<?php the_permalink($posts->ID) ?>">
       	                      <?php echo $post-> post_title;//mb_substr(strip_tags($post-> post_title),0,40).'...'; ?>
       	                    </a>
       	                  </div>
   
   
       				</li>
   
       <?php
         endforeach;
         wp_reset_postdata();
   
         $to_show -= count( $posts );  // 表示した分を減らす
         // 先祖タームを取得
         // 現在の投稿に2つ以上タームがある場合、最初のタームに絞って先祖を取得
         $ancestors = get_ancestors( reset( $ids ), $mytax, 'taxonomy' );
         if ( count( $ancestors ) < 2 ) {
           break;  // 親タームがないので表示終わり
         }
         $ids = array( $ancestors[1] );  // 親タームを次の対象にする
       endwhile;       
       ?>
       <?php wp_reset_query(); ?>
   
       </ul>
       ```
   
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [タームの階層のループ](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%ae%e9%9a%8e%e5%b1%a4%e3%81%ae%e3%83%ab%e3%83%bc%e3%83%97/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%ae%e9%9a%8e%e5%b1%a4%e3%81%ae%e3%83%ab%e3%83%bc%e3%83%97/#post-225940)
 * 失礼いたしました
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-225902)
 * すいません、ソースが汚かったです。。。
 * まず、条件として５位までランキングを出したいです。
 * 下記のソースでカスタム投稿の
    **記事詳細と同じタームのランキング**は表示されます。
   しかし、この場合ですとタームに3つしか記事がなかった場合、 ３位までしかでません、
   なので、その場合は一つ上位のタームからも拾って、 ５位まで表示されるまで階層を
   登って行きたいです。
 *     ```
       <ul class="list-ranking">       
       <?php	 
        global $post;
        $ids = wp_get_object_terms( $post->ID, 'column_category', array( 'fields' => 'ids' ) );
   
        $args = array(
         'posts_per_page' => 5,
         'post_type' => 'column',
         'meta_key' => 'views',
         'orderby' => 'meta_value_num',
           'tax_query' => array( array(
       		'taxonomy' => 'column_category',
       		'terms' => $ids,
       		'include_children' => false, // ← 追加		  
       		'operator' => 'AND', // 'IN', 'NOT IN', 'AND' 等
       	)),
        );
        $posts = get_posts($args);
       ?>
       <li class="media kanshu">
             <!-- ランキング順位 -->
             <div class="rank"><?php echo $i;?></div>
             <!-- サムネイル -->
             <div class="media-left">
               <a href="<?php the_permalink($posts->ID) ?>"><?php the_post_thumbnail($posts->ID,'thumb'); ?></a>
             </div>
             <!-- 記事 -->
             <div class="media-body">
               <a href="<?php the_permalink($posts->ID) ?>">
                 <?php echo $post-> post_title;//mb_substr(strip_tags($post-> post_title),0,40).'...'; ?>
               </a>
             </div>
       </li>
       <?php endforeach; wp_reset_query();?>
       </ul>
       ```
   
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-225898)
 * ここまで書いてみたのですが、どうでしょうか？？
 *     ```
           <ul class="list-ranking">
   
        <?php
   
       //現在のタームのidを取得
       $term_id = get_queried_object()->term_id;
   
       //祖先タームのidを取得
       $ancestors = get_ancestors( $term_id, 'my_taxonomy' );
   
       //get_ancestors()は孫から親への順番で配列になるので、順番を入れ替える
       $reversed_ancestors = array_reverse($ancestors); 
   
   
       	         global $post;
       	         $ids = wp_get_object_terms( $post->ID, 'column_category', array( 'fields' => 'ids' ) );
   
                    $args = array(
       			  'posts_per_page' => 5,
                     'post_type' => 'column',
                     'meta_key' => 'views',
                     'orderby' => 'meta_value_num',
                     /*'tax_query' => array( array(
       					'taxonomy' => 'column_category',
       					'terms' => $ids,
       					'include_children' => false, // ← 追加		  
       					'operator' => 'AND', // 'IN', 'NOT IN', 'AND' 等
       				) ),
       */
                    );
   
                     $posts = get_posts($args);
       //print_r($posts);
   
       if( !empty( $myposts ) )://もし記事が空でなかったら
                     $i = 0;
                     foreach($posts as $post) :
                     $i++;              
                   ?>
       	            <li class="media kanshu">
       	                  <!-- ランキング順位 -->
       	                  <div class="rank"><?php echo $i;?></div>
       	                  <!-- サムネイル -->
       	                  <div class="media-left">
       	                    <a href="<?php the_permalink($posts->ID) ?>"><?php the_post_thumbnail($posts->ID,'thumb'); ?></a>
       	                  </div>
       	                  <!-- 記事 -->
       	                  <div class="media-body">
       	                    <a href="<?php the_permalink($posts->ID) ?>">
       	                      <?php echo $post-> post_title;//mb_substr(strip_tags($post-> post_title),0,40).'...'; ?>
       	                    </a>
       	                  </div>
   
   
   
       	                <!--監修-->			    
       					<?php 
       							$writers = get_posts(array(
       								'post_type' => 'doctor',
       								'meta_query' => array(
       									array(
       										'key' => 'doctor_supervision', // name of custom field
       										'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
       										'compare' => 'LIKE'
       									)
       								)
       							));
   
       							?>
   
       							<?php if( $writers ): ?>
       							<?php foreach( $writers as $writer ): ?>
       							    <div id="relation">
       								      <div class="media-left">
       									      <a href="<?php echo get_the_permalink($writer->ID); ?>">
       										       <?php echo get_the_post_thumbnail($writer->ID,'doc_thum' ); ?>
       									      </a>
       									  </div>
       									  <div class="article">
       										医師監修 	<span class="clinic">
       													<?php the_field('doctor_clinic', $writer->ID); ?>
       												</span> <a href="<?php echo get_permalink( $writer->ID ); ?>">
       														<?php echo get_the_title( $writer->ID ); ?>
       													</a> <?php the_field('keisho', $writer->ID); ?>
       									  </div>
       							    </div>
   
       							<?php endforeach; wp_reset_query();?>
       							<?php endif; ?>
       							<!--//監修-->
       				</li>
   
       <?php endforeach; wp_reset_query();?>
   
   
       <li>準備中です。</li>
       <?php endif; ?>
       <?php wp_reset_query(); ?>
   
       </ul>
       ```
   
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [記事がなかったら祖先タームから取得方法](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e8%a8%98%e4%ba%8b%e3%81%8c%e3%81%aa%e3%81%8b%e3%81%a3%e3%81%9f%e3%82%89%e7%a5%96%e5%85%88%e3%82%bf%e3%83%bc%e3%83%a0%e3%81%8b%e3%82%89%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95/#post-225893)
 * ５に満たない場合というのは５件に満たない場合という意味です
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [AMP for WordPressで画像が出ない](https://ja.wordpress.org/support/topic/amp-for-wordpress%e3%81%a7%e7%94%bb%e5%83%8f%e3%81%8c%e5%87%ba%e3%81%aa%e3%81%84/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 7ヶ月前](https://ja.wordpress.org/support/topic/amp-for-wordpress%e3%81%a7%e7%94%bb%e5%83%8f%e3%81%8c%e5%87%ba%e3%81%aa%e3%81%84/#post-225861)
 * 原因がわかりました。
    function に書かれた非同期jquryの記述でした。 消したら表示
   されました。 ありがとうございます。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [AMP for WordPressで画像が出ない](https://ja.wordpress.org/support/topic/amp-for-wordpress%e3%81%a7%e7%94%bb%e5%83%8f%e3%81%8c%e5%87%ba%e3%81%aa%e3%81%84/)
 *  トピック投稿者 [iguigu](https://ja.wordpress.org/support/users/iguigu/)
 * (@iguigu)
 * [8年、 7ヶ月前](https://ja.wordpress.org/support/topic/amp-for-wordpress%e3%81%a7%e7%94%bb%e5%83%8f%e3%81%8c%e5%87%ba%e3%81%aa%e3%81%84/#post-225635)
 * 出ました！
    プラグイン有効にしても問題ないので、 テーマの何かが原因ですね、、

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

1 [2](https://ja.wordpress.org/support/users/iguigu/replies/page/2/?output_format=md)
[3](https://ja.wordpress.org/support/users/iguigu/replies/page/3/?output_format=md)
[→](https://ja.wordpress.org/support/users/iguigu/replies/page/2/?output_format=md)