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

I have a custom plugin 'Charts' that has it's own menu. In that menu are links to the 3 pages for the plugin - 'Charts', 'Add Chart' and 'Edit Chart'. However, I don't want to display the link to 'Edit Chart'.

Here is how I add the page in question -

$this->pagehook = add_submenu_page('charts', __('Edit Chart'), __('Edit Chart'), 'edit_charts', 'edit-chart', array(&$this, 'on_show_page'));

I've scoured the internet, and cannot find a way to do this (that works). It's possible to remove whole top level menus (not what I need), and you can remove individual entries from the $submenu global (but doing that also removes the registered capability), so no one can access the page -

global $submenu;
if(!empty($submenu['charts'])) : foreach($submenu['charts'] as $key => $page) :
        if($page[0] === 'Edit Chart') :

            /** Removes all permissions to access the page */
            /** Removes the title, but the menu entry still exists, so it looks odd */
            $submenu['charts'][$key][0] = '';


I've looked in to hiding it via CSS, but can't see a way to do that through the HTML that Wordpress generates -

<li><a href="admin.php?page=edit-chart" tabindex="1">Edit Chart</a></li>

I've also considered jQuery, but that has similar limitations to the CSS route, plus I refust to believe that I am the only one that has ever wished to do this - there must be a way, I just can't find it!

Any hints and tips appriciated.


share|improve this question
Where are you hooking this function? What filter/action? – s_ha_dum Nov 22 '12 at 14:45
up vote 4 down vote accepted

Use a submenu page as parent slug. The admin menu has just two levels, so the imaginary third level will be hidden.

Sample code, tested:

add_action( 'admin_menu', 'wpse_73622_register_hidden_page' );

function wpse_73622_register_hidden_page()
    # /wp-admin/admin.php?page=wpse_73622

function wpse_73622_render_hidden_page()
    echo '<p>hello world</p>';
share|improve this answer
Beautiful, works like a charm. Thanks for the quick reply. – David Gard Nov 22 '12 at 15:02
Works beautifully! – Manuel Meurer Jan 13 '15 at 19:18

From the docs on add_submenu_page(), you see that you can hide your submenu link from a top level menu item to which it belongs be setting the slug (1st argument) to null:

add_action( 'admin_menu', 'register_my_custom_submenu_page' );

function register_my_custom_submenu_page() {
        'My Custom Submenu Page',
        'My Custom 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.