Last active
October 30, 2018 14:43
-
-
Save nfsarmento/43f432d382bb5f2f2e5c30a86fb86ee2 to your computer and use it in GitHub Desktop.
This function makes posts in the admin filterable by the author
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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