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  /  April 25  /   18

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

Subscribe to this weekly newsletter to receive the latest blog posts by email.I respect your privacy. Your email is safe with me.

Comments 18

← Older
  • Great post, easy to implement! Any idea if it’s possible to do the same to user groups created using User Groups (https://wordpress.org/plugins/user-groups/) ?

    • MishaAuthor August 9, 2017 at 08:01

      Hi Joana,

      Hmmm… try to play with restrict_manage_posts hook priority, set it to 1 and if it doesn’t help – to 9999.

Leave your question or feedback

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