以下をfunctions.phpに追加します。
ex. customName
という名前のカスタム投稿で、area
という名前のカスタムタクソノミーで絞り込む場合の例です。
適宜修正してください。
//カスタム投稿一覧をタクソノミーで絞り込んで表示 add_filter('pre_get_posts', 'set_post_order_in_customName'); function set_post_order_in_customName($wp_query) { global $current_user, $pagenow; if (is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby']) && $wp_query->query_vars['post_type'] == 'customName') { $user_area = 'area1'; //絞り込み表示したいカスタムタクソノミーのスラッグをセット $wp_query->set('area', $user_area);//選択したエリアで絞り込み。 $screen = get_current_screen(); add_filter('views_'.$screen->id, 'fix_post_counts'); } } // 一覧の投稿数を修正 function fix_post_counts($views) { global $current_user, $wp_query; unset($views['mine']); $set_posttype = $wp_query->query_vars['post_type']; $types = array( array('status' => NULL), array('status' => 'publish'), array('status' => 'draft') ); $user_area = 'area1'; //絞り込み表示したいカスタムタクソノミーのスラッグをセット foreach($types as $type) { $query = array( 'area' => $user_area, 'post_type' => $set_posttype, '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='."$set_posttype"), $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='."$set_posttype"), $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='."$set_posttype"), $result->found_posts); elseif($type['status'] == 'mine'): $class = ($wp_query->query_vars['post_status'] == 'mine') ? ' class="current"' : ''; $views['mine'] = sprintf(__('<a href="%s"'. $class .'>'. __('Mine') .' <span class="count">(%d)</span></a>', 'mine'), admin_url('edit.php?post_status=mine&post_type='."$set_posttype"), $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='."$set_posttype"), $result->found_posts); endif; } return $views; }