Wordpress - getting posts from multiple authors?
wordpress
Solution
If you want to retrieve posts from multiple authors, you need to use the `author__in` parameter
query_posts( array( 'author__in'=> array_keys($following) , 'paged' => $paged, ) );
Problem
Using a third party plugin that allows users to follow each other, we can retrieve the users being followed like so (commented):- ``` <?php if (have_posts()) : ?> <?php global $userpro_social; $following = $userpro_social->following( get_current_user_id() ); //get users the current user is following print_r($following) ?> // print the array so we can see who we're following <?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; ?> <?php query_posts( array( 'author'=> ??? , 'paged' => $paged, ) ); ?> <?php while ( have_posts() ) : the_post() ?> <?php if ( has_post_format( 'video' )) { get_template_part( 'video-post' ); }elseif ( has_post_format( 'image' )) { get_template_part( 'image-post' ); } else { get_template_part( 'standard-post' ); } ?> <?php endwhile;?> <?php endif; ?> ``` So this would output something like this Array ( [24] => 1 [1] => 1 ) ie, we're following users with the ID of 1 and 24, simple enough? The part I'm lost on is this ``` <?php query_posts( array( 'author'=> ??? , 'paged' => $paged, ) ); ?> ``` How do I actually output posts from those users, it's already stored in the array so I think it should be easy enough, but I just can't figure it out even after reading the codex.