Submenus are menu items listed below your top-level menu and menu item listed below existing default menus in WordPress admin panel. We will examine how to make a submenu in admin panel WordPress. I assumed, you are created a menu or add to the default menu in the admin panel. Here, we created a menu named Webkul Products as shown in image below :-

You can see how to add a menu to WordPress admin panel.
Now we are creating a submenu named Add Product under the Menu( Webkul Product -> Add Module )
You can use add_submenu_page() function explained below: –
add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $callback = ”, int|float $position = null ): string|false
This function takes a capability which will be used to determine whether or not a page is included in the menu.
The function which is hooked in to handle the output of the page must check that the user has the required capability as well.
Parameters
$parent_slug
( string Required ) :- This slug passed as name for the parent menu or you can pass the file name of a standard WordPress admin page.$page_title
( string Required ) :- This text will displayed in the page as title tags when we will select the menu.$menu_title
( string Required ) :- This will display text on menu as label$capability
( string Required ) :- Capability is required for displaying menu item$menu_slug
( string Required ) :- This slug name is refer to menu and should be unique for this menu item and will only include alphanumeric, lowercase , dashes, and underscores letter.$callback
( callable Optional ) :-$position
( int|float Optional ) :- A function to call to return the content of this page.
Default is :null
$position
( int|float Optional ) :- The position in the menu order to display this item.
Default is :null
Just follow these steps and add this code in function.php file :-
1. Create a custom function and use add_submenu_page() :-




2. Create callback function and pass in add_submenu_page() : –




3. Now add a function to add_action with an action hook ( admin_menu ) : –




add_action -> Add a callback function to your action hook.
admin_menu -> Fires earlier than the admin menu is loaded in Admin.




Output:-




If you need custom WordPress Development services then feel free to reach us.
Reference
https://developer.wordpress.org/reference/functions/add_submenu_page/#parameters
!!Have a Great Day Ahead!!