Back WordPress

How to Display Posts only from Current User

WRITTEN BY ON 10 May 2011

When a contributor in a multi-user site see the post list in the admin page, he could see not only his posts, but also posts from other contributors. Even he couldn’t edit the other posts, this still could be a problem if there’s alot post already and he have to search from page to page to find his posts. How about displaying his post only? This snippet will show how to do it.


Simply put the code into your theme functions.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' );

Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.