Filter Posts by Author in wp-admin

When working on my company’s intranet site, we realized that we wanted to be able to quickly sort through all the posts by a particular author and didn’t necessarily want to switch between the front-end and wp-admin.

It took me a while to be able to find the hook for this, because it’s name doesn’t lend itself to be found easily: restrict_manage_posts

I finally found this post by Misha Rudrastyh: https://rudrastyh.com/wordpress/filter-posts-by-author.html

My Google searches kept returning code samples for custom taxonomies and custom post types and this was all I needed.

/**
 * This section makes posts in the admin filterable by the author.
 */
add_action('restrict_manage_posts', 'rose_filter_by_author');
function rose_filter_by_author() {
	$params = array(
		'name' => 'author', 
		'show_option_all' => 'All Authors' 
	);
	if ( isset($_GET['user']) ) {
		$params['selected'] = $_GET['user'];
	}
	wp_dropdown_users( $params );
}