How to show only Author’s Post and Hide all other posts in wordpress

In this tutorial I’ll show you how you can Hide all Posts  from Author which are published by Admin or  other Author from Author. It is very simple to do this.

What you’ll need is just put this code in “function.php” page which are located in your current theme right?

// Hide Admin’s and Author’s all Post from another Authors

function posts_for_current_author($query) {
global $pagenow;

if( ‘edit.php’ != $pagenow || !$query->is_admin )
return $query;

if( !current_user_can( ‘edit_others_posts’ ) ) {
global $user_ID;
$query->set(‘author’, $user_ID );
}
return $query;
}
add_filter(‘pre_get_posts’, ‘posts_for_current_author’);

News Reporter

Leave a Reply

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