Add filter for Post Type — ‘project’.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
// Post Type Project add_filter( 'views_edit-project', 'wpm_add_project_filter' ); function wpm_add_project_filter( $views ) { global $wp_query; $my_cat = 38; // Replace with your category ID $query = array( 'post_type' => 'project', 'post_status' => 'publish', 'cat' => $my_cat ); $cat_object = get_category( $my_cat ); $result = new WP_Query( $query ); $class = ( $wp_query->query_vars['cat'] == $cat_object->slug ) ? ' class="current"' : ''; $views['publish_f'] = sprintf( __( '<a href="%s"' . $class . '>' . $cat_object->name . ' <span class="count">(%d)</span></a>', $cat_object->name ), admin_url( 'edit.php?post_status=publish&post_type=project&cat=' . $my_cat ), $result->found_posts ); return $views; } |