サポート » 使い方全般 » Popular Postsをquery_postsで取得

  • wordpressのPopular Postsをquery_postsで取得する記事をみつけたのでんですが少々困っています。
    functions.phpに追加

    
    //popular post からquery_posts生成
    function get_popular_args($range= "weekly", $limit = 8){
      //urlを作成
      $shortcode = '[wpp';
      $atts = '
              post_html="{url},"           
              wpp_start=""
              wpp_end=""
              order_by="views"
              post_type="post"
              stats_comments=0
              stats_views=1
                ';
      $atts_2 = ' range='. $range;
      $atts_3 = ' limit='. $limit;
      $shortcode .= ' ' . $atts . $atts_2 . $atts_3 . ']';
      $result = explode(",", strip_tags(do_shortcode( $shortcode )));
      $ranked_post_ids = array();
       
      //urlから投稿IDを作成
      foreach($result as $_url){        
        if(!empty($_url) && trim($_url) != ''){
          $id_string = url_to_postid($_url);
          array_push ($ranked_post_ids, intval($id_string));
        }
      }
       
      //idをreturn
      $args = array(
        'posts_per_page' => 20,
        'post__in' => $ranked_post_ids,
        'orderby' => 'post__in'
      );
      
      return $args;
    }

    表示場所に下記を記入 月間人気記事を10件取得

    
    <?php $args = get_popular_args('monthly', '10');
    query_posts($args); ?>
    

    サイドバーに表示させるには問題は無いのですが固定ページで全ての投稿のランキングを表示させる
    場合、全ての投稿が一括で表示されてしまいページネーションが使えません。

    「100件中 1位 ~ 10位 まで表示」され、ページ送り以降は「11位 ~ 20位」と成る様にするには
    どうすれば良いのでしょうか?

    ヘルプの必要なページ: [リンクを見るにはログイン]

1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「Popular Postsをquery_postsで取得」には新たに返信することはできません。