Filter Posts by Author in the Admin List
Adds an author dropdown next to the date and category filters, so editors can list one writer's posts.
Opens WPIDE on
Code
add_action( 'restrict_manage_posts', function ( $post_type ) {
if ( ! post_type_supports( $post_type, 'author' ) || ! current_user_can( 'edit_others_posts' ) ) {
return;
}
wp_dropdown_users( array(
'name' => 'author',
'show_option_all' => 'All authors',
'selected' => isset( $_GET['author'] ) ? absint( $_GET['author'] ) : 0,
'capability' => array( 'edit_posts' ),
'hide_if_only_one_author' => true,
) );
} );
Notes
WordPress already understands the author filter; this snippet only adds the dropdown.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.