default_featured_How-to-add-the-author-filter-in-WordPress-admin
Home » Blog » WordPress » How to add the author filter in WordPress admin

How to add the author filter in WordPress admin

Updated:   WordPress 2 min read

Your support helps keep this blog running! Secure payments via Paypal and Stripe.


Recently, I worked on a project that requested to show all posts for each author. What I did, was to create the author.php and fetch all posts based on the current author slug. I added the Ajax pagination as well. Moreover, the requirement is to show the number of posts that belong to the author as well. So adding the author filter in the WordPress admin will help in rechecking the correct number of posts.

Add code to functions.php

The simple way to add the author filter is to add the code via functions.php of the active theme. I expect to add to the child theme. Another way, you can add the code via your own plugin.

Note that if you have already configured the parent theme via the customizer, you can still switch to the child theme without losing the customizer configuration by using a helpful plugin.

Now, add the code below to the functions.php

function ar_adding_author_filter( $post_type ) {
	if( 'books' !== $post_type ) {
		return;
	}

	$selected_author = isset( $_GET[ 'author' ] ) && $_GET[ 'author' ] ? $_GET[ 'author' ] : '';

	wp_dropdown_users(
		array(
			'role__in' => array(
				'administrator',
				'editor',
				'author',
				'contributor'
			),
			'name' => 'author',
			'show_option_all' => 'All authors',
			'selected' => $selected_author
		)
	);
}
add_action( 'restrict_manage_posts', 'ar_adding_author_filter' );

Change the post type

In my case, I show the author filter only for the “books” custom post type. So I check the post type before adding the author filter.

You can comment on this post type checking out if you don’t need to.

If you want to show the author filter only on the Posts that belong to the blog page. You can change from “books” to “post” since “post” is a post type of blog page.

Add query parameter

Next, I get the query parameter using $_GET. The author is a variable I need to supply to $_GET. I will use this author value in the dropdown list that I am creating below. You can inspect the query parameter by checking the URL in the browser after clicking on the filter button.

Add a dropdown list

After that, I create the users dropdown list using wp_dropdown_users(). It will create the user dropdown list for you. The selected author will be selected in the dropdown list as shown in the code.

Add filter

Finally, we add our “ar_adding_author_filter” function to the restrict_manage_posts action hook. That’s it.

Other posts

Additionally, if you are looking to add the custom taxonomy filter in the WordPress admin, check my post.

This post is helpful and saves you time, please consider buying me a coffee. Keep me awake and write more posts for saving your time.


Your support helps keep this blog running! Secure payments via Paypal and Stripe.


Senior WordPress Developer (Freelancer)

Senior WordPress Developer (Freelancer)

I’m a professional WordPress and WooCommerce developer based in Chiang Mai, Thailand, with over a decade of experience creating fast, secure, and scalable websites. From custom themes and plugins to full WooCommerce stores, I help businesses build a strong and reliable online presence. Need a freelance WordPress developer you can count on? View my portfolio or get in touch to discuss your project.