Hack: Show Authors Only Their Own Posts

When authors that contribute to your WordPress site look at the list of posts, they see all of the posts, even if they can’t edit them. It would be nicer for them, and perhaps a bit more secure for you, if you could hide all of the posts that are not theirs.

This little bit of code, added to your functions.php file or custom plugin, doesn’t really provide any extra security. It just makes the posts list look nicer and easier for authors to deal with. Note that the change excludes anyone with the permission to edit all posts, so admins won’t be affected.

add_filter('pre_get_posts', 'wpfilter_pre_get_posts');
function wpfilter_pre_get_posts($query) {
	global $pagenow, $user_ID;
 	if (($pagenow == 'edit.php') && (!current_user_can('edit_others_posts'))) {
		$query->set('author', $user_ID);
	return $query;

Leave a Reply

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