How to only display the author posts in the admin post list

Paste the code below into your functions.php file. Once you saved the file, authors will only see their own posts in the admin post list.

<?php

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' );

?>

Thanks to WP Snippets for the code!

Leave a Reply

Your email address will not be published. Required fields are marked *