WordPress TutorialRemove Version from WordPress and StylesheetsRun WordPress local with XAMPPSecurity in WordPress - EscapingSecurity in WordPress - SanitizationThe Loop (main WordPress loop)Update WordPress ManuallyWordPress Actions and FiltersWordPress add action()WordPress add editor style()WordPress add menu page()WordPress Add ShortcodeWordPress add submenu page()WordPress add theme support()WordPress Add/remove contact info for users with user contactmethods filter hookWordPress Admin Dashboard WidgetsWordPress AJAXWordPress Alternating main loop (pre get posts filter)WordPress Child Theme BasicsWordPress Create a Post ProgrammaticallyWordPress Create Template for Custom Post TypeWordPress Creating a custom templateWordPress Custom exerpts with excerpt length and excerpt moreWordPress Custom Post TypesWordPress Customizer Basics (Add Panel, Section, Setting, Control)WordPress Customizer Hello WorldWordPress DebuggingWordPress Enqueuing scriptsWordPress Enqueuing StylesWordPress Function : wp trim words()WordPress Function: add action()WordPress get bloginfo()WordPress get home path()WordPress get option()WordPress get permalink()WordPress get template part()WordPress get the category()WordPress get the title()WordPress home url()WordPress How Can I integrate Markdown editor with Advance Custom Fields repeater Add-on.WordPress initWordPress Installation and ConfigurationWordPress Making network requests with HTTP APIWordPress Meta BoxWordPress Options APIWordPress Plugin creationWordPress Plugin developmentWordPress Post FormatsWordPress Querying postsWordPress Remove Auto Line Breaks from Content and ExcerptWordPress REST APIWordPress Secure your installationWordPress ShortcodeWordPress Shortcode with attributeWordPress ShortcodesWordPress SidebarsWordPress Site MigrationWordPress TaxonomiesWordPress Template hierarchyWordPress template includeWordPress the $wpdb ObjectWordPress the Admin Bar (aka The Toolbar)WordPress the title()WordPress theme and child-theme developmentWordPress ThemesWordPress wp get current user()WordPress WP Query() LoopWordPress WP-CLIWordPress WP-Cron

WordPress add submenu page()

From WikiOD

This function is to add a sub-item to an existing item in the admin panels nav bar.

Syntax[edit | edit source]

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

Parameters[edit | edit source]

Parameter Details
$parent_slug (string) The slug name for the parent menu (or the file name of a standard WordPress admin page).
$page_title (string) The text to be displayed in the title tags of the page when the menu is selected.
$menu_title (string) The text to be used for the menu.
$capability (string) The capability required for this menu to be displayed to the user.
$menu_slug (string) The slug name to refer to this menu by (should be unique for this menu).
$function (callable) (Optional) The function to be called to output the content for this page.

Remarks[edit | edit source]

Here are a list of slugs for $parent_slug

  • Dashboard: ‘index.php’
  • Posts: ‘edit.php’
  • Media: ‘upload.php’
  • Pages: ‘edit.php?post_type=page’
  • Comments: ‘edit-comments.php’
  • Custom Post Types: ‘edit.php?post_type=your_post_type’
  • Appearance: ‘themes.php’
  • Plugins: ‘plugins.php’
  • Users: ‘users.php’
  • Tools: ‘tools.php’
  • Settings: ‘options-general.php’
  • Network Settings: ‘settings.php’

Adding the "Submenu Page" as a sub-page of "Tools" to the nav bar[edit | edit source]


add_action('admin_menu', 'register_my_custom_submenu_page');

function register_my_custom_submenu_page() {
        'Submenu Page',
        'My Custom Submenu Page',
        'my_custom_submenu_page_content' );

function my_custom_submenu_page_content() {
    echo '<div class="wrap">';
        echo '<h2>Page Title</h2>';
    echo '</div>';




In the code, we created a function named register_my_custom_submenu_page and we used add_submenu_page to add the item to the navbar as a child of tools.php, which is the Tools page.

Please check the parameters part in this page to know about the arguments we passed in. Then we used add_action to run our register_my_custom_submenu_page function. Finally, we created the function my_custom_submenu_page_content to display contents in the page.