1

I have a case like below.

enter image description here

Confused how to use the wpQuery to achieve this

This is for a single user. Not sure how can i pass the array.

global $current_user;
get_currentuserinfo();                      

$args = array(
    'author'        =>  $current_user->ID, 
    'orderby'       =>  'random',
    'post_per_page' => '1',
    'order'         =>  'ASC' 
    );

$current_user_posts = get_posts( $args );

1 Answer 1

2

Use author__in not author as a query parameter.

$authors = [ 1, 2, 3, ];

$current_user_posts = get_posts( [
    'author__in'    =>  $authors, 
    'orderby'       =>  'random',
    'post_per_page' => '1',
    'order'         =>  'ASC' 
] );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.