0

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(); ?>

    <h2>Hello</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.

0

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
);
  • that's what i did if you check my code above you 'll see that. But thank you for your time. – user76156 Jan 23 '16 at 1:43
  • No, u did not. the add_submenu_page accepts only 6 arguments, but you have passed 8. Thank yourself for your time :). – Pmpr Jan 23 '16 at 1:45
  • I have done that also and i tried it again. But no submenu to be found under my plugin. Shouldn't i get a page as a submenu that says hello or am i wrong? – user76156 Jan 23 '16 at 10:52
  • Any new idea??? – user76156 Jan 23 '16 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy