WordPress add submenus to custom menu

Create Menu

add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );

Create a sub menu

add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function);

Note

In situations where a plugin is creating its own top-level menu, the first submenu will normally have the same link title as the top-level menu and hence the link will be duplicated. The duplicate link title can be avoided by calling the add_submenu_page function the first time with the parent_slug and menu_slug parameters being given the same value.

 

 

function clivern_plugin_top_menu(){
add_menu_page('Eastview Custom', 'Eastview Custom', 'manage_options', 'my-top-level-handle');
add_submenu_page( 'my-top-level-handle', 'GLS Lunch Orders', 'GLS Lunch', 'manage_options', 'my-top-level-handle','my_custom_menu_page');
add_submenu_page( 'my-top-level-handle', 'New Item', 'New item', 'manage_options', 'new-handle','my_custom_menu_page1');
}
add_action('admin_menu','clivern_plugin_top_menu');

Leave a comment