Title: Setup Top Level Admin Menu
Last modified: August 18, 2016

---

# Setup Top Level Admin Menu

 *  [explor1ng](https://wordpress.org/support/users/explor1ng/)
 * (@explor1ng)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/setup-top-level-admin-menu/)
 * I’m trying to create custom admin menu, seeing the example here [http://codex.wordpress.org/Adding_Administration_Menus](http://codex.wordpress.org/Adding_Administration_Menus)
   but it seems not working. When I click on ‘Test Toplevel’ it goes to [http://mydomain/mydir/wp-admin/testtoplevel](http://mydomain/mydir/wp-admin/testtoplevel),
   is this example correct? do I need to put relative path to my plugin directory?
 * Here I paste the example on that page:
 *     ```
       // Hook for adding admin menus
       add_action('admin_menu', 'mt_add_pages');
   
       // action function for above hook
       function mt_add_pages() {
   
           // Add a new top-level menu (ill-advised):
           add_menu_page('Test Toplevel', 'Test Toplevel', 8, 'testtoplevel', 'mt_toplevel_page');
   
           // Add a submenu to the custom top-level menu:
           add_submenu_page(__FILE__, 'Test Sublevel', 'Test Sublevel', 8, 'sub-page', 'mt_sublevel_page');
   
           // Add a second submenu to the custom top-level menu:
           add_submenu_page(__FILE__, 'Test Sublevel 2', 'Test Sublevel 2', 8, 'sub-page2', 'mt_sublevel_page2');
       }
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [explor1ng](https://wordpress.org/support/users/explor1ng/)
 * (@explor1ng)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/setup-top-level-admin-menu/#post-613650)
 * Need help on this.
 * What I have tried is:
 *     ```
       add_menu_page('Test Toplevel', 'Test Toplevel', 8, '../wp-content/plugins/myplugindir/myplugin.php');
       add_submenu_page('../wp-content/plugins/myplugindir/myplugin.php', 'Test Sublevel', 'Test Sublevel', 8, '../wp-content/plugins/myplugindir/myplugin.php', 'mt_sublevel_page');
       add_submenu_page('../wp-content/plugins/myplugindir/myplugin.php', 'Test Sublevel 2', 'Test Sublevel 2', 8, 'sub-page2', 'mt_sublevel_page2');
       ```
   
 * It works, but looks bad, please tell me if there’s a better way.
 *  Thread Starter [explor1ng](https://wordpress.org/support/users/explor1ng/)
 * (@explor1ng)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/setup-top-level-admin-menu/#post-613687)
 * can anyone confirm this?
 *  [Dazzer](https://wordpress.org/support/users/dazzer/)
 * (@dazzer)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/setup-top-level-admin-menu/#post-613790)
 * I’d like to bump this. Facing the same issue here.
 * edit:
 * I might have hacked it.
 *     ```
       add_menu_page('Artworks', 'Artworks', 9, __FILE__,'printArtworksAdmin');
       add_submenu_page(__FILE__, 'Artworks','Artworks',9,__FILE__,'printArtworksAdmin');
       add_submenu_page(__FILE__, 'Projects','Projects',9,'projectsAdmin','printProjectsAdmin');
       ```
   
 * Set the First Submenu’s unique identifier to __FILE__. Very strange behaviour.
 *  [nicholutso](https://wordpress.org/support/users/nicholutso/)
 * (@nicholutso)
 * [18 years ago](https://wordpress.org/support/topic/setup-top-level-admin-menu/#post-613819)
 * I have some custom code that lives outside the wp-admin folder, and its linked
   to correctly in menu.php it spits out a page with a form on it. At the top of
   the page I use:
    <?php require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-admin/admin.
   php’); $title = __(‘Edit Inns’); $this_file = ‘inn.php’; $parent_file = ‘inn.
   php’; require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-admin/admin-header.php’);?
   > to pull in the wordpress admin menu, but its not pulling in my plugin menu 
   items (specifically cforms II) any suggestions?
 *  [pipelineae](https://wordpress.org/support/users/pipelineae/)
 * (@pipelineae)
 * [18 years ago](https://wordpress.org/support/topic/setup-top-level-admin-menu/#post-613820)
 * [@dazzer](https://wordpress.org/support/users/dazzer/)
 * Why would you set the unique identifier to __FILE__?
 * Creating custom admin menus is really very easy.
 * __FILE__ refers to the file that will handle the display of the admin page you
   wish to create. The submenu’s unique identifier is just a name that will be sent
   via GET to the page that handles it, hence why it has to be unique, and not __FILE__…

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Setup Top Level Admin Menu’ is closed to new replies.

## Tags

 * [add_menu_page](https://wordpress.org/support/topic-tag/add_menu_page/)

 * 5 replies
 * 4 participants
 * Last reply from: [pipelineae](https://wordpress.org/support/users/pipelineae/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/setup-top-level-admin-menu/#post-613820)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
