Answers for "Get authors who has posts in category - WordPress"

0

Get authors who has posts in category - WordPress

$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
) );
Posted by: Guest on September-23-2021

Code answers related to "Get authors who has posts in category - WordPress"

Browse Popular Code Answers by Language