Filter posts by author in WordPress admin area

Maybe you have already read the post about custom taxonomy filter on my blog. And now I will show you how to create the same filter by the authors. The filter will work not only for posts but also for pages and custom post types. Here it is: This code is for your current theme […]

#wp-admin  /  January 18, 2016  /   13

Maybe you have already read the post about custom taxonomy filter on my blog. And now I will show you how to create the same filter by the authors.

The filter will work not only for posts but also for pages and custom post types.

Here it is:

How to filter all posts by authors in WP administration area.

This code is for your current theme functions.php file:

function rudr_filter_by_the_author() {
	$params = array(
		'name' => 'author', // this is the "name" attribute for filter <select>
		'show_option_all' => 'All authors' // label for all authors (display posts without filter)
	);
 
	if ( isset($_GET['user']) )
		$params['selected'] = $_GET['user']; // choose selected user by $_GET variable
 
	wp_dropdown_users( $params ); // print the ready author list
}
 
add_action('restrict_manage_posts', 'rudr_filter_by_the_author');

Only the best of WordPress

once a week, no spam

Comments 13

Leave your question or feedback

phpjsHTMLCSSSQLCode
Please, enter a comment
Please, enter a name
Incorrect email