一つのWordpressで複数のユーザーが管理するサイトを作成することになりました。
すべてを編集できる管理者と各ユーザー毎にカスタム投稿を作成して自分の分の投稿のみ編集可能にしていたのですがユーザー数が増減することがあり、投稿をすべてまとめてしまおうと思って全部投稿にまとめたのですが
問題点として、自分以外の人が書いた投稿も閲覧、編集可能な状態になってしまいました。
これでは不都合です。
そういうわけで色々なサイトを参考に修正してみました。

<?php
//自分以外の投稿を非表示
function my_pre_get_posts_filter(&$wp_query)
{
    global $pagenow;
    $user = wp_get_current_user();
 
    if (is_admin() && ($post_type = $wp_query->get('post_type'))) {
	
		// メディアの表示情報を制限
        if (in_array($pagenow, array('media-upload.php', 'upload.php')) && $post_type == 'attachment' && !current_user_can( 'administrator' )) {
            $wp_query->set('author', $user->ID);			//投稿者IDを付与
			add_filter('views_upload', 'fix_media_counts');	//表示数フィルター
        }
		
		//投稿の表示情報を制限
        if (in_array($pagenow, array('edit.php', 'edit-tags.php')) && !current_user_can( 'administrator' )) {
			$screen = get_current_screen();
			add_filter('views_'.$screen->id, 'fix_post_counts');	//表示数フィルター
			$wp_query->set('author', $user->ID);					//投稿者IDを付与
        }		

		//投稿編集を制限
		if(in_array($pagenow, array('post.php'))){
			$p = get_post($_REQUEST["post"]);
			if($user->ID != $p->post_author && !current_user_can( 'administrator' )){
				wp_die( __('You are not allowed to edit posts.'));
			}
		}
		
    }	
}
add_action('pre_get_posts', 'my_pre_get_posts_filter', 10, 1);

// Fix post counts
function fix_post_counts($views) {
    global $current_user, $wp_query,$post_type;
    unset($views['mine']);
    $types = array(
        array( 'status' =>  NULL ),
        array( 'status' => 'publish' ),
        array( 'status' => 'draft' ),
        array( 'status' => 'trash' )
    );
	if(empty($wp_query->query_vars['post_status'])){$wp_query->query_vars['post_status']=NULL;}
    foreach( $types as $type ) {
                $query = array(
                    'author'      => $current_user->ID,
                    'post_type'   => $post_type,//全投稿タイプで対応できるようにするため、ここは投稿タイプで取得する
                    'post_status' => $type['status']
                );
                $result = new WP_Query($query);
                if($type['status'] == NULL):
               $class = ($wp_query->query_vars['post_status'] == NULL)  ? ' class="current"' : '';
               $views['all'] = sprintf(__('<a href="%s"'. $class  .'>' . __('All') . ' <span class="count">(%d)</span></a>', 'all'),
                    admin_url('edit.php?post_type='.$post_type),
                    $result->found_posts);
          elseif($type['status'] == 'publish'):
               $class = ($wp_query->query_vars['post_status'] == 'publish') ? ' class="current"' : '';
               $views['publish'] = sprintf(__('<a href="%s"'. $class .'>' . __('Published') . ' <span class="count">(%d)</span></a>', 'publish'),
                    admin_url('edit.php? post_status=publish&post_type='.$post_type),
                    $result->found_posts);
          elseif($type['status'] == 'draft'):
               $class = ($wp_query->query_vars['post_status'] == 'draft') ? ' class="current"' : '';
               $views['draft'] = sprintf(__('<a href="%s"'. $class .'>'. __('Draft') . ((sizeof($result->posts) > 1) ? "s" : "") .' <span class="count">(%d)</span></a>', 'draft'),
                    admin_url('edit.php?post_status=draft&post_type='.$post_type),
                    $result->found_posts);
          elseif($type['status'] == 'pending'):
               $class = ($wp_query->query_vars['post_status'] == 'pending') ? ' class="current"' : '';
               $views['pending'] = sprintf(__('<a href="%s"'. $class .'>'. __('Pending') .' <span class="count">(%d)</span></a>', 'pending'),
                    admin_url('edit.php?post_status=pending&post_type='.$post_type),
                    $result->found_posts);
          elseif($type['status'] == 'trash'):
               $class = ($wp_query->query_vars['post_status'] == 'trash') ? ' class="current"' : '';
               $views['trash'] = sprintf(__('<a href="%s"'. $class .'>'. __('Trash') .' <span class="count">(%d)</span></a>', 'trash'),
                    admin_url('edit.php?post_status=trash&post_type='.$post_type),
                    $result->found_posts);
          endif;
    }
    return $views;
}
 
// Fix media counts
function fix_media_counts($views) {
     global $wpdb, $current_user, $post_mime_types,  $avail_post_mime_types;
     $views = array();
     $count = $wpdb->get_results("
          SELECT post_mime_type, COUNT( * ) AS num_posts
          FROM $wpdb->posts
          WHERE post_type = 'attachment'
          AND post_author = $current_user->ID
          AND post_status != 'trash'
          GROUP BY post_mime_type
     ", ARRAY_A );
     foreach($count as $row)
          if ($count && $row != 0) {
               $_num_posts[$row['post_mime_type']] = $row['num_posts'];
               $_total_posts = array_sum($_num_posts);
               $detached = isset($_REQUEST['detached']) || isset($_REQUEST['find_detached']);
          };
     if (!isset($total_orphans))
          $total_orphans = $wpdb->get_var("
               SELECT COUNT( * )
               FROM $wpdb->posts
               WHERE post_type = 'attachment'
               AND post_author = $current_user->ID
               AND post_status != 'trash'
               AND post_parent < 1
          ");
     $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
     foreach ($matches as $type => $reals)
          foreach ($reals as $real)
               $num_posts[$type] = ( isset($num_posts[$type])) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
     $class = (empty($_GET['post_mime_type']) && !$detached && !isset($_GET['status'])) ? ' class="current"' : '';
     $views['all'] = "<a href='upload.php'$class>" . sprintf(__(__('All') .' <span class="count">(%s)</span>', 'uploaded files'), number_format_i18n($_total_posts)) . '</a>';
     foreach ( $post_mime_types as $mime_type => $label ) {
          $class = '';
          if (!wp_match_mime_types($mime_type, $avail_post_mime_types))
               continue;
          if (!empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']))
               $class = ' class="current"';
          if (!empty( $num_posts[$mime_type]))
               $views[$mime_type] = "<a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), $num_posts[$mime_type]) . '</a>';
     }
     $views['detached'] = '<a href="upload.php?detached=1"' . ($detached ? ' class="current"' : '') . '>' . sprintf(_x('Unattached <span class="count">(%s)</span>', 'detached files'), $total_orphans) . '</a>';
     return $views;
}

//メディアの挿入のクエリーを制限
function filter_ajax_query_attachments( $query ) {
	$user = wp_get_current_user();
        if (!current_user_can( 'administrator' )) {
            $query['author'] = $user->ID;
        }
		return $query;
}
add_filter( 'ajax_query_attachments_args', 'filter_ajax_query_attachments' );


?>

参考サイト
WordPressを複数ユーザーで利用している際に、「投稿」や「メディア」で自分が投稿したもの以外を表示させないようにするコード
http://inspire-tech.jp/2012/11/view-of-the-posts-and-media-only-myself/

投稿したユーザー以外の編集、閲覧禁止
http://ja.forums.wordpress.org/topic/43034?replies=3

WordPress管理画面カスタマイズあれこれ10選
http://liginc.co.jp/web/wp/customize/29851