Select Page

How to add submenu in WordPress admin panel

Anikesh Kumar
Published: November 24, 2022

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_pagestring $parent_slugstring $page_titlestring $menu_titlestring $capabilitystring $menu_slugcallable $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.


  1. $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.
  2. $page_title ( string Required ) :- This text will displayed in the page as title tags when we will select the menu.
  3. $menu_title ( string Required ) :- This will display text on menu as label
  4. $capability ( string Required ) :- Capability is required for displaying menu item
  5. $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.
  6. $callback ( callable Optional ) :-
  7. $position ( int|float Optional ) :- A function to call to return the content of this page.
    Default is : null
  8. $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() :-

Function Definition

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

Callback Function

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.

add_action -> admin_menu




If you need custom WordPress Development services then feel free to reach us.


!!Have a Great Day Ahead!!