Skip to content

Instantly share code, notes, and snippets.

@nfsarmento
Last active October 30, 2018 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfsarmento/43f432d382bb5f2f2e5c30a86fb86ee2 to your computer and use it in GitHub Desktop.
Save nfsarmento/43f432d382bb5f2f2e5c30a86fb86ee2 to your computer and use it in GitHub Desktop.
This function makes posts in the admin filterable by the author
/**
* This function makes posts in the admin filterable by the author.
*
* https://www.nuno-sarmento.com
*/
function ns_filter_by_the_author() {
$params = array(
'name' => 'author', // this is the "name" attribute for filter <select>
'show_option_all' => 'All authors' // label for all authors (display posts without filter)
);
if ( isset($_GET['user']) )
$params['selected'] = $_GET['user']; // choose selected user by $_GET variable
wp_dropdown_users( $params ); // print the ready author list
}
add_action('restrict_manage_posts', 'ns_filter_by_the_author');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment