WordPress add_submenu_page() Adding the "Submenu Page" as a sub-page of "Tools" to the nav bar



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>';


enter image description here


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.