Here are a list of slugs for $parent_slug
Code
add_action('admin_menu', 'register_my_custom_submenu_page');
function register_my_custom_submenu_page() {
add_submenu_page(
'tools.php',
'Submenu Page',
'My Custom Submenu Page',
'manage_options',
'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>';
}
Output
Explanation
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.
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. |