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; } |
1 2 3 4 5 6 7 |
function wpm_admin_menu_items() { global $menu; $menu[10] = $menu[26]; // set position unset( $menu[26] ) // delete old element position } add_action( 'admin_menu', 'wpm_admin_menu_items' ); |
When you create a custom post type, you should edit this option for setting you post type menu in admin:
1 |
'menu_position' => 5, // 5 - this is right under the Posts menu element |
This list is very usefull. It represents a hierarchy preset of menu elements in WordPress admin menu: