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 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. –  Jay 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. –  Jay Sep 4 '13 at 6:31

Your Answer


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

Browse other questions tagged or ask your own question.