WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the theme admin menu below, the "MyTheme Menu Label" is being duplicated twice on the sidebar menu, once for the main menu link and again for the first submenu link.

How can I remove the 2nd instance of the link

    get_bloginfo('template_directory') .'/img/favicon.png',31

    "SEO Options",

    "Misc Options",

share|improve this question
up vote 3 down vote accepted

There is a workaround to hide this automatically created submenu. In the past I've used it quite often, but lately I have returned to leaving it as is (or renaming it, as m0r7if3r suggested).

Also note, that aside your main question, you have switched the positions of the menu_slug and function arguments in add_menu_page, see the codex for reference.

This is how it is done anyhow:

/* Add top level menu */
    'MyTheme Menu Label',
    'theme_admin',        // menu slug
    'functions.php',        // function
    get_bloginfo('template_directory') .'/img/favicon.png',

/* remove duplicate menu hack */
    'theme_admin',        // parent slug, same as above menu slug
    '',        // empty page title
    '',        // empty menu title
    'edit_themes',        // same capability as above
    'theme_admin',        // same menu slug as parent slug
    'functions.php',        // same function as above

This isn't too clean, but afaik the only way to hide the duplicate submenu.

share|improve this answer

From the codex page on admin menus:

In situations where a plugin is creating its own top-level menu, the first submenu will normally have the same link title as the top-level menu and hence the link will be duplicated. The duplicate link title can be avoided by calling the add_submenu_page function the first time with the parent_slug and menu_slug parameters being given the same value.

Personally, I think that it would be bad practice to do anything but rename the top link, as it would break consistency with the rest of the admin bar.

share|improve this answer

There's a function that should cover this:

remove_submenu_page( $plugin_slug, $plugin_slug );
share|improve this answer

protected by Community Aug 24 '15 at 15:00

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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