How to get authors who have added the post in the specific custom post type
I have a custom post called event
and I have to show all the authors who have added the post. I have tried the below code but I am getting all the users on the page.
For example. There are 4 users called A, B, C, and D on the website and A and B added the post.
Now I have to get only A and B users but below code getting all the users like A,B,C,D
Any idea how to get the user to add the post in the event post type.
$users = get_users( array( 'fields' = array( 'ID','display_name' ),'order' = 'ASC', 'who' ='authors' ));
foreach ($users as $user){
$userid=$user-ID;
//echo $post_count = count_user_posts($userid);
echo 'lia href='.esc_url(get_author_posts_url($userid)).''.$user-display_name.'/a/li';
}
Topic list-authors theme-development plugins Wordpress
Category Web