I’m using the code below from another answer to query posts from 1 custom role, eg “friends”. I thought I could just comma separate the roles to list posts from more than one role, but this didn’t work. Is there another way I can write it? I’ve tried 'role' => 'friends', 'enemies'
and 'role' => 'friends, enemies'
but I guess get_users
only supports one role.
<?php
$friends = get_users( array( 'role' => 'friends' ) );
$friend_ids = array();
foreach( $friends as $friend )
$friend_ids[] = $friend->ID;
$news = new WP_Query( array( 'author' => implode( ',', $friend_ids ), 'post_type' => 'news', 'paged' => get_query_var('paged') ) ); ?>