Search code examples
wordpressadminsubmenu

Add submenu page in admin menu in wordpress


I would like create a submenu page under my theme option page

My theme option code:

 function add_new_menu_items()
    {
        add_menu_page(
            "Theme Options",
            "Theme Options",
            "manage_options",
            "theme-options",
            "theme_options_page",
            "", 
            99
        );
    }
    add_action("admin_menu", "add_new_menu_items");

This is my submenu code, but it not functional:

function my_plugin_menu() {
    add_submenu_page( 
    'edit.php?post_type=theme-options', 
    'Registrations', 
    'Registrations', 
    'manage_options', 
    'theme-options-registrations', 
    'wwpr_page_call' 
);
}
add_action('admin_menu', 'my_plugin_menu');

Thanks for the help.


Solution

  • function my_plugin_menu() {
      add_submenu_page( 
        'theme-options', 
        'Registrations', 
        'Registrations', 
        'manage_options', 
        'theme-options-registrations', 
        'wwpr_page_call' 
      );
    }
    

    Changing 'edit.php?post_type=theme-options' to the slug of the parent menu (in this case 'theme-options') will fix your problem.