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 would like to add my new developed plugin's admin menu to an existing plugin as sub menu. Would be possible to do this?

In my first plugin I initilize the menus as follows:

function add_pages() {
    // Add a new top-level menu (ill-advised):
    add_menu_page(__('MyMenu','menu-test'), __('MyMenu','menu-test'), 'manage_options', 'menu-top-level-handle', array ($this , 'menu_toplevel_page' ) );

    // Add a second submenu to the custom top-level menu:
    add_submenu_page('menu-top-level-handle', __('Test Submenu','menu-test'), __('Test Submenu','menu-test'), 'manage_options', 'sub_page_test', array($this , 'test_sublevel_page2') );

The code in the second plugin:

function admin_menu () {    
    add_submenu_page( 'menu-top-level-handle', 'Lexikon', 'Lexikon', 'manage_options', 'lexikon-edit', array($this , 'lexikon_settings_page') );

Then I tried the following in my second plugin, but the page is wrong redirected instead: admin.php?page=sub_page redirects to /sub_page.

share|improve this question
up vote 2 down vote accepted

Trying to simulate the issue, it happened the same (wp-admin/submenu_slug), and the solution is to add a priority value in the hook admin_menu.

Here, I'm adding a sub menu to the plugin BackWPup. Note the priority 11:

add_action('admin_menu', 'third_party_submenu_wpse_91377', 11 );

function third_party_submenu_wpse_91377() 
        'backwpup', // Third party plugin Slug 
        'My plugin', 
        'My plugin', 

function plugin_options_wpse_wpse_91377() 
    echo '<h1>OK</h1>'; 

enter image description here

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.