Wednesday, March 20, 2013

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

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

In a multi-author blog, the code is very useful to allow each author to only see his own posts in the wordpress admin post list. The following is a simple code snippet to do it.

So you have to paste the code below into the theme functions.php file. Now saved the file, and then authors will only see only their own posts in the admin post list.

<?php

function mypo_parse_query_adminonly( $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_adminonly' );

?>


No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off