我希望获得我最受欢迎的帖子,并且我使用yuzo插件进行计数视图..但是这段代码不起作用..我怎样才能使它工作?
$popular = new WP_Query( array(
'post_type' => array( 'post' ),
'showposts' => $instance['popular_num'],
'cat' => $instance['popular_cat_id'],
'ignore_sticky_posts' => true,
'orderby' => 'wpng_yuzoviews.views',
'order' => 'dsc',
'date_query' => array(
array(
'after' => $instance['popular_time'],
),
),
) );
答案 0 :(得分:3)
您的查询将类似于:
$query = new WP_Query( array(
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'posts_per_page' => 5
) );
默认情况下,订单将从最高到最低,从而为您提供" top" 5。