Adding submenu to custom plugin menu page created with add_menu_page() function

I have created a custom menu page using add_menu_page() function. Everything in that page appears as it should in the screen. What I am trying to achieve is adding another submenu under the under the page i previously created(i want it to appear just like when you click on the settings menu in wordpress dashboard). I am pasting a code snippet below:

    //creating the menu item for the plugin
function qpv_custom_menu_link() {
    add_menu_page(
        'Quick Product View Options',
        'Quick Product View',
        'manage_options',
        'qpv-options',
        'qpv_options_page',
        '',
        '100'
    );
    add_submenu_page(
        'qpv-options',
        'Quick Product View Appearance',
        'Quick Product View Appearance Settings',
        'manage-options',
        'qpva-options',
        'qpva_options_page'
    );


}

add_action( 'admin_menu', 'qpv_custom_menu_link' );


//creating the submenu page settings
function qpva_options_page(){

    ob_start(); ?

    h2Hello/h2


    ?php
    echo ob_get_clean();
}

I have also checked the wordpress codex and have followed the given instructions, but my problem remains and the submenu page still does not show up in under the plugin name.

Topic add-menu-page add-submenu-page plugin-development plugins Wordpress

Category Web


You may take use of add_submenu_page function:

Add a top-level menu page

add_menu_page(
    $page_title,
    $menu_title,
    $capability,
    $menu_slug,
    $function,
    $icon_url,
    $position
);

Add a sub-menu page

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

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.