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.
{code type=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 );
}
}
}
FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.
FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.
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: