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 […]

Published on /Updated on /28 comments

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');

Related Posts

Need some help with WordPress?

If you need some professional developer help, I will be happy to assist you.

Contact me Who I am?

Comments — 28

← Next comments

Comments are closed