I have created a custom loop to show only admin posts, but now I would like it to display posts from both admins and contributors.
Any help is GREATLY appreciated!
Here is what I have so far:
echo "<div class='post_wrap " . $infinite . "'>";
$users_query = new WP_User_Query( array(
'role' => 'administrator',
'orderby' => 'display_name'
) );
$site_admins = array();
$results = $users_query->get_results();
foreach($results as $user) {
$site_admins[] = $user->ID;
}
$admins = implode(',',$site_admins);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array('post_type' => 'post', 'author' => $admins, 'paged' => $paged, 'posts_per_page' => 10));
while (have_posts()) : the_post();
@1fixdotio :
WP_User_Query
returns an object of each user.WP_Query
takes user ids only so we have to extract the ids from the user objects. I think that is the only mistake there.