WordPress Popular Posts のランキングを無理やりquery_postsで取得し直す

    $shortcode = '[wpp';
    $atts = '
post_html="{url},"            
 wpp_start=""
 wpp_end=""
 order_by="views"
 range="monthly"
 stats_comments=0
 stats_views=1
 limit=20
';
    $shortcode .= ' ' . $atts . ']';
    $result = split(',', strip_tags(do_shortcode( $shortcode )));
    $ranked_post_ids = array();
    
    foreach($result as $_url){        
        if(!empty($_url) && trim($_url) != ''){
           $replaced_url = preg_replace("/.*\/archives\/([0-9]+).*/", "$1", $_url);
           $id_string = preg_replace("/[^0-9]/", "", $replaced_url);
           if($id_string) {
                array_push ($ranked_post_ids, intval($id_string));
           }
        }
    }
    
    $args = array(
                'posts_per_page' => 20,
                'post__in' => $ranked_post_ids,
                'orderby' => 'post__in'
            );
    query_posts($args);