📌  相关文章
📜  获取在类别中有帖子的作者 - WordPress - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:49.132000             🧑  作者: Mango

代码示例1
$barcelona_posts = get_posts('cat=59');
$barcelona_author_ids = array();

foreach ( $barcelona_posts as $k => $v ) {
    if ( ! in_array( $v->post_author, $barcelona_author_ids ) ) {
        $barcelona_author_ids[] = $v->post_author;
    }
}

$barcelona_authors = get_users( array(
    'fields' => 'ID',
    'who'    => 'authors',
    'order'  => 'DESC',
    'orderby'=> 'post_count',
    'include' => $barcelona_author_ids
) );