1

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.

1
  • I know I have found myself in this same situation over and over, and that the solution was very easy, and yet I can't find it again. Commented Jan 4 at 9:32

1 Answer 1

1

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
);
4
  • that's what i did if you check my code above you 'll see that. But thank you for your time.
    – user76156
    Commented Jan 23, 2016 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 :). Commented Jan 23, 2016 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
    Commented Jan 23, 2016 at 10:52
  • Any new idea???
    – user76156
    Commented Jan 23, 2016 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.