管理画面にログインしている人だけの投稿を表示する@WordPress

function posts_for_current_author($query) {
 global $pagenow;
 if( 'edit.php' != $pagenow and !$query->is_admin )
 return $query;
 if( !current_user_can( 'manage_options' ) ) {
 global $user_ID;
 $query->set('author', $user_ID );
 }
		$screen= get_current_screen();
		add_filter('views_'.$screen->id, '__return_empty_array');
 return $query;
}

add_filter('pre_get_posts', 'posts_for_current_author');

Restricting authors to view only posts they created@source

その2

function exclude_other_posts( $wp_query ) {
	
 if ( isset( $_REQUEST['post_type'] ) and
 	 post_type_exists( $_REQUEST['post_type'] ) ) {
		
 $post_type= get_post_type_object( $_REQUEST['post_type'] );
 $cap_type= $post_type->cap->edit_other_posts;
 } else {
 $cap_type= 'edit_others_posts';
 }

 if ( is_admin() and
 	 $wp_query->is_main_query() and
		 ! $wp_query->get( 'author' ) and
		 ! current_user_can( $cap_type ) ) {
		
 $user= wp_get_current_user();
 $wp_query->set( 'author', $user->ID );
 }
}

add_action( 'pre_get_posts', 'exclude_other_posts' );

@source

[emulsion_relate_posts]