I currently have the following custom wp_query which displays posts from 2 custom WP roles, "custom_role_one" and "custom_role_two". It displays the posts from my custom post type of "listing". It works great but how can I modify this so that the posts are ordered by each role?
For example, I would like all posts from "custom_role_one" to be displayed first and then all posts from "custom_role_two" to be listed second. As you can see, they are currently ordered by date.
<?php $custom_roles = get_users( array( 'role' => 'custom_role_one, custom_role_two' ) );
$custom_ids = array();
foreach( $custom_roles as $custom_role )
$custom_ids[] = $custom_role->ID;
$custom_role_query = new WP_Query( array( 'author' => implode( ',', $custom_ids ), 'post_type' => 'listing', 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC', 'paged' => get_query_var('paged') ) );
?>
<?php if ( $custom_role_query ->have_posts() ) : while ( $custom_role_query ->have_posts() ) : $custom_role_query ->the_post(); ?>
<div id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
</div>
<?php endwhile; endif; ?>
<?php wp_reset_postdata(); ?>