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

/29 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

Misha Rudrastyh

Misha Rudrastyh

I love WordPress, WooCommerce and Gutenberg so much. 10 yrs of experience.

Need some custom developer help? Let me know

Follow Misha

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 — 29

Leave a comment

php js HTML CSS Code

I will only use your personal information to contact you. Privacy Policy