我的问题是如何通过$count_fb
对此条目进行排序?
似乎我无法添加像$the_query = new WP_Query('orderby='.$count_fb.'&posts_per_page=6');
$count_fb
字符串
这是代码:
$the_query = new WP_Query('orderby='.$count_fb.'&posts_per_page=6');
while ( $the_query->have_posts() ) : $the_query->the_post();
$url = get_permalink($post->ID);
$fb_file = file_get_contents('https://graph.facebook.com/?ids=' . $url);
$json = json_decode($fb_file);
$count_fb = $json->$url->comments;
if ($count_fb == 0 || !isset($count_fb)) {
$count_fb = 0;
}
echo 'https://graph.facebook.com/?ids='.$url.$count_fb;
echo '<br />';
endwhile;
wp_reset_postdata();
答案 0 :(得分:0)
您可以尝试将参数作为数组而不是字符串传递:
$query = new WP_Query( array ('orderby' => $count_fb, 'posts_per_page' => '6'));