Wordpress php排序查询

时间:2012-01-19 02:53:29

标签: wordpress sorting

我的问题是如何通过$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();

1 个答案:

答案 0 :(得分:0)

您可以尝试将参数作为数组而不是字符串传递:

$query = new WP_Query( array ('orderby' => $count_fb, 'posts_per_page' => '6'));