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. Does not work at all.

  2. HEIN MIN KYAW HTWE June 26, 2019 at 1:34 am

    I Love Children.

Add a Comment

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!