Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question already has an answer here:

I am creating a submenu with the following code:

add_action( 'admin_menu', 'jp_create_admin_pages' );

function jp_create_admin_pages()
{
    add_menu_page(
        'Members',
        'Members',
        'manage_options',
        'members',
        'jp_handle_admin_members');

    add_submenu_page(
        'members',
        'Membership Types',
        'Membership Types',
        'manage_options',
        'jp_handle_admin_membership_types');
}

This creates a custom menu called 'Members' with two sub-menus: 'Members' and 'Membership Types'.

I want to make it so that the first submenu is called 'All Members' instead of 'Members' (to mirror the built in menu types). Any ideas?

share|improve this question

marked as duplicate by toscho May 3 '13 at 15:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

The first menu item typically is the parent item and shares the name with that item, you can however manually update the entry directly in the $submenu variable, like so..

add_action( 'admin_menu', 'jp_create_admin_pages' );

function jp_create_admin_pages() {
    global $submenu;
    add_menu_page('Members','Members','manage_options','members','jp_handle_admin_members');
    add_submenu_page('members','Membership Types','Membership Types','manage_options','membership_types','jp_handle_admin_membership_types');
    $submenu['members'][0][0] = 'All Members';
}

That way your parent keeps the original name, whilst the first subitem has another.

Hope that helps.

share|improve this answer
    
Note, your add_submenu_page call was missing the callback(it's the 6th arg), i've added a menu slug and moved what i'd assume is your callback down to the 6th param. –  t31os May 3 '13 at 15:49

Have you tried changing the Menu title to 'All Membership Types'?

add_submenu_page(
        'members',
        'Membership Types',
        'All Membership Types',
        'manage_options',
        'jp_handle_admin_membership_types');

http://codex.wordpress.org/Function_Reference/add_submenu_page

Not sure if it's possible to do it any other way.

I know what you are trying to achieve, like when registering a custom post type. There is actually a field for All Items that's built into the labels array.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.