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.
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!
Snippet Not Working. Please update this. Thanks!!
Does not work at all.