Documentation List Posts By A Co-Author

List Posts By A Co-Author

When using Co-Authors Plus, you may want to create a listing of all posts by a given co-author. Co-Authors Plus deviates slightly from how core WordPress works in that it stores byline information in a custom ‘author’ taxonomy. It works in this manner because a post (let it be a Post, Page, or Custom Post Type) can have multiple taxonomy terms associated with it.

To list some or all posts from a co-author, you’ll want to create a new WP_Query object based on theĀ author term for a given user or guest author. Here’s an example of what that might look like:

// Build the query arguments
$args = array(
	'post_type' => 'post',
	'posts_per_page' => 10,
	'post_status' => 'publish',
	'author_name' => $user_login,
);
$author_query = new WP_Query( $args );

if ( $author_query->have_posts() ) :
	while ( $author_query->have_posts() ) : $author_query->the_post();

	// Do your presentation

	endwhile;
endif;