X

How to Add ‘Show Posts by Author’ Filter Menu to Admin Posts List

Snippets by IsItWP

Are you looking for a way to add ‘show posts by author’ filter menu to admin posts list? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add ‘show posts by author’ filter menu to admin posts list in WordPress.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

/*
add authors menu filter to admin post list for custom post type
*/
function restrict_manage_authors() {
	if (isset($_GET['post_type']) && post_type_exists($_GET['post_type']) && in_array(strtolower($_GET['post_type']), array('CUSTOM_POST_TYPE', 'CUSTOM_POST_TYPE_2'))) {
		wp_dropdown_users(array(
			'show_option_all'	=> 'Show all Authors',
			'show_option_none'	=> false,
			'name'			=> 'author',
			'selected'		=> !empty($_GET['author']) ? $_GET['author'] : 0,
			'include_selected'	=> false
		));
	}
}
add_action('restrict_manage_posts', 'restrict_manage_authors');

function custom_columns_author($columns) {
    $columns['author'] = 'Author';
    return $columns;
}
add_filter('manage_edit-CUSTOM_POST_TYPE_columns', 'custom_columns_author');

Make sure to replace CUSTOM_POST_TYPE to your post type name in the above code.

Credits/thanks to Trevor Morris.

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 11 best WordPress plugins for writers and how to properly start a blog.

Comments   Leave a Reply

  1. to the folks complaining this does not work: if you cannot read and understand a little bit of code, you should probably not even try this.
    It works perfectly, you just have to change CUSTOM_POST_TYPE to “post” (or “page” depending on what you want) and if you want the second “CUSTOM_POST_TYPE2” either use it or remove it.
    Thanks to the author!

  2. Snippet Not Working. Please update this. Thanks!!

  3. Does not work at all.

Add a Comment Cancel reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!