Php WordPress。根据作者的文章受欢迎程度/查看最多次数创建作者列表,并以零篇文章隐藏

Php WordPress。根据作者的文章受欢迎程度/查看最多次数创建作者列表,并以零篇文章隐藏,php,wordpress,Php,Wordpress,我有一个多作者的WordPress博客,有自定义的文章类型和分类法。 在我的自定义分类法存档页面中,我想显示按照特定自定义分类法撰写文章的作者列表,并按其文章视图的顺序排列 下面是我从WP初学者那里用来记录帖子视图的函数代码: function wpb_set_post_views($postID) { $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true);

我有一个多作者的WordPress博客,有自定义的文章类型和分类法。 在我的自定义分类法存档页面中,我想显示按照特定自定义分类法撰写文章的作者列表,并按其文章视图的顺序排列

下面是我从WP初学者那里用来记录帖子视图的函数代码:

function wpb_set_post_views($postID) {
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
我测试过,自定义帖子有这样一个元值,它随着每个帖子视图的增加而存储和增加。 在我的自定义分类归档页面中,我使用以下查询参数:

 $args = array(
   'post_type' => custom_post,
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'meta_key' => 'wpb_post_views_count',
    'orderby' => 'meta_value_num',
    'order' => 'DESC',
    'hide_empty' => 1,
    'tax_query' => array(
       array(
       'taxonomy' => custom_taxonomy,
       'field' => 'slug',
       'terms' => custom_term_slug,
       ),
    ),
 );
并使用以下代码获取作者列表:

$authors = get_users($args);
    foreach ($authors as $author) {
        $auth_name = $author->display_name;
        $auth_post_count = count_user_posts($author->ID);
        echo $auth_name;
        echo $auth_post_count;
    }
我没有从上述代码中获得作者列表,但是当我从
$args
中删除以下两个时,即使没有帖子(0篇帖子),我也会获得作者列表:

我如何显示按文章流行度排序的作者列表,并隐藏无文章

'meta_key' => 'wpb_post_views_count',
'orderby' => 'meta_value_num',