Author Filter in WordPress admin
There is already a tutorial about custom taxonomy filter on my blog. Now it is time how to create a similar filter by authors.
Please note, that the filter is going to work for every registered post type by default unless you add a custom condition in the beginning of the function.
And here is how it is going to look like

All you need to do is to paste the following code to functions.php
file of your current theme (not necessary that file by the way, please read more here).
add_action( 'restrict_manage_posts', 'rudr_filter_by_the_author' );
function rudr_filter_by_the_author( $post_type ) {
// you can add a condition for a specific post type
// if( 'my_type' !== $post_type ) {
// return;
// }
$selected = isset( $_GET[ 'user' ] ) && $_GET[ 'user' ] ? $_GET[ 'user' ] : '';
wp_dropdown_users(
array(
'role__in' => array(
'administrator',
'editor',
'author',
'contributor'
),
'name' => 'author',
'show_option_all' => 'All authors',
'selected' => $selected
)
);
}

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
thanks. It’s perfect!
Worked perfectly! Thanks
Great work. Thanks!
Very nice..
Exactly what I needed. Thanks.
Great,
Is it possible to show author by role ?
Hi,
I recommend you to use
get_users()
instead ofwp_dropdown_users()
function.I would like to give you the working example but I’m in the mountains right now and replying you from my iPhone. Please look WP docs for more info about
get_users()
usage.Hi Misha,
And how about date of post creation?
Regards!
Nikola
Hi Nicola,
what do you mean ?
Filter by dates is already included by default, isn’t it? :)
Hi
Thanks for your replay!
Yes it is included by month,
How about date or date range :)
Regrads!
Hi,
it looks like the new post idea :) it is the good news. The bad news that you should wait for it for a week. If you can wait, I will write and publish it – just let me know.
Hi Nikola,
the post about date range filter is ready, you can find it here :)
Hi Misha,
I saw your post on facebook.
Thanks!
Thanks, very useful.
Awesome post,
Is there anyway to create a filter like this for a taxonomy?
Hi Jared,
Try this.
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/) ?
Hi Joana,
Hmmm… try to play with
restrict_manage_posts
hook priority, set it to 1 and if it doesn’t help – to 9999.Cool!
Is there a way to get first_name and last_name in the dropdown menu?
Hi Ivan,
Fantastic basic and clear way!
Add extra section for this code use this link.
https://codex.wordpress.org/Function_Reference/wp_dropdown_users
Is there a way to limit the filter menu to include only privileged users?
Yes, you can use
role
(accepts string),role__in
(accepts array) orrole__not_in
(accepts array) params ofwp_dropdown_users()
function.Example:
Awesome, thanks! :)
Thanks, perfect :)
AWESOME
This is perfect code, only one issue that i am facing. It shows a list of authors but with – author selected by default. The selected author is the author of post that appears on top of the page. Is there a way to not to select author in the filter by default?
Hey Raj,
Strange, for me it doesn’t show author by default.
Thanks a ton – what a great and simple solution :-)
thank you, it perfectly works.
Nice code helped me a lot to filter out a ton of posts. Is there a way to apply this code to the Pages section in the admin area?