To see the the current array keys try this:
add_action( 'admin_menu' , 'admin_menu_new_items', 1 );
function admin_menu_new_items() {
global $submenu;
wp_die( '<pre>' . var_export( $submenu['edit.php'], true ) . '</pre>' );
}
I get this:
array (
5 =>
array (
0 => 'All Posts',
1 => 'edit_posts',
2 => 'edit.php',
),
10 =>
array (
0 => 'Add New',
1 => 'edit_posts',
2 => 'post-new.php',
),
15 =>
array (
0 => 'Categories',
1 => 'manage_categories',
2 => 'edit-tags.php?taxonomy=category',
),
16 =>
array (
0 => 'Tags',
1 => 'manage_categories',
2 => 'edit-tags.php?taxonomy=post_tag',
),
)
Index ’10’ is the Add New item. To add the new sub menu items use indexes 11, 12 and 13:
$submenu['edit.php'][11] = array( 'Add New Profile', 'manage_options' , '/wp-admin/post-new.php?post_cat=pitches' );
$submenu['edit.php'][12] = array( 'Add New News', 'manage_options' , '/wp-admin/post-new.php?post_cat=news' );
$submenu['edit.php'][13] = array( 'Add New Pitch', 'manage_options' , '/wp-admin/post-new.php?post_cat=pitch' );
When WordPress adds the sub menu items to the dashboard it treats$submenu
as an associative array. Any items added to theedit.php
array will be added to the end of array regardless of the key used. Use ksort() to order the keys.
ksort( $submenu['edit.php'], SORT_NUMERIC );
Putting it all together:
add_action( 'admin_menu' , 'admin_menu_new_items', 1 );
function admin_menu_new_items() {
global $submenu;
$submenu['edit.php'][11] = array( 'Add New Profile', 'manage_options' , '/wp-admin/post-new.php?post_cat=pitches' );
$submenu['edit.php'][12] = array( 'Add New News', 'manage_options' , '/wp-admin/post-new.php?post_cat=news' );
$submenu['edit.php'][13] = array( 'Add New Pitch', 'manage_options' , '/wp-admin/post-new.php?post_cat=pitch' );
// WordPress treats $submenu as an associative array and does not sort it first.
// We have to sort keys into the order we want them to show up.
ksort( $submenu['edit.php'], SORT_NUMERIC );
}