How to Show Only the Author’s Posts in the Edit List

Every now and then users on the forums request a way to show only the author’s own posts in the “All Posts” screen. Here’s a quick snippet that you can add to your theme’s functions.php file.

Adding this code will restrict the posts page to display only the author’s own posts, instead of posts created by all authors on the site.

1
2
3
4
5
6
7
8
9
10
function mypo_parse_query_useronly( $wp_query ) {
    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
        if ( !current_user_can( 'level_10' ) ) {
            global $current_user;
            $wp_query->set( 'author', $current_user->id );
        }
    }
}

add_filter('parse_query', 'mypo_parse_query_useronly' );

This code snippet comes to you courtesy of our friends at WP-Snippets. Add it to your site if you want to keep authors from getting into each other’s posts.

Tags

Participate