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

This is the current situation:

  • I am writing a plugin that has a top-level menu page
  • The plugin also contains other sub-menu pages
  • The sub-menu pages are not assigned a parent slug (thus they do not appear in the admin menu)

My requirement is to do the following:

  • Have only the top-level menu page menu item in the admin menu (no sub-menu page menu items should appear)
  • Highlight the top-level menu page menu item when on a sub-menu page

I've tried giving a parent slug to the sub-menu pages. This, of course, makes it appear as expected under the top-level menu item. I then tried to remove the sub-menu item, by using remove_submenu_page. However, since that removes the entire sub-menu page, it doesn't solve the problem.

I believe the logical thing to do, is to give a parent slug, since the top-level menu item will need to know that the page being accessed falls under it. The problem then, is not showing the sub-menu page's menu item. I am unable to find a function that deals directly with the menu items.

Is this the right approach or is there a better alternative? Is there a action/filter/hook I can utilise to carry out what I need to do?

Edit #1:
Did some further research/testing. Setting the menu_title parameter to null or '' in the add_submenu_page call makes the title not appear. However, the <li> that contains the sub-menu item still does exist and can be interacted with. When there are numerous sub-menu pages (as in my case), the empty <li> elements will add-up and create a long blank area on the menu. This is far from ideal and as such, I'm still searching for a solution.

Edit #2: Tried manipulating the $submenu global after the comment from @s_ha_dum. However, any removal of the menu section pertaining to a page also results in removing the page similar to remove_submenu_page and thus rendering that page inaccessible.

share|improve this question
Unfortunately, that method seems to work similar to remove_submenu_page and makes accessing the page throw a "You do not have sufficient permissions to access this page." message. I'll check up further on it though. Thanks for the suggestion. – Jayawi Perera Sep 2 '13 at 3:39
Would a tabbed interface within your main page achieve the same goal? getbutterfly.com/… – epilektric Sep 3 '13 at 23:07
That's an interesting approach. I'm not entirely sure I want to have all the different pages (there are about 8 or so in total) loading in tabs though. I suppose I could do some AJAX loading where the individual page content is loaded as and when it is needed. I'm still interested in finding a solution for the original problem. However, I think it may not be possible for the current WP version without modifying the core files (which I do not wish to do). I'll check out the tabbed approach. Thanks for the suggestion. – Jayawi Perera Sep 4 '13 at 6:31

That's a bit of a late answer and I don't know if @Jay ever sorted it out, but to anyone having the same issue, here's how I fixed it.

Menu Pages

function my_admin_menu() {

        'Page title',
        'Menu title',

        'Subpage 1 title',
        'Subpage 1 menu title',

        'Subpage 2 title',
        'Subpage 2 menu title',
add_action( 'admin_menu', 'my_admin_menu' ) );

function my_admin_head() {

    remove_submenu_page( 'my_page', 'my_subpage_1' );
add_action( 'admin_head', 'my_admin_head' );

See the Codex for remove_submenu_page.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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