I want to add the parameter for the submenus, but when I click to the admin page I get the following message:

it throwing Sorry, you are not allowed to access this page.

add_menu_page( 'Main Menu', '', $min_access_cap, 'main-main', array($this, 'main_menu'), $icon_url, 999 );


add_submenu_page( 'main-menu', sprintf( __( '%1$s ‹ %2$s', 'main-menu' ), $title['page_title'], 'Submenu' ), $title['admin_menu_title'], $min_access_cap, 'page=settings&submenu=page2', array($this, 'sub_menu') );


I have created the submenu link but the problem it's now showing the page. It's showing access denied.

How can I solve this issue?


1 Answer 1


I have checked your code. You are using incorrect menu-slug in add_submenu_page. Because admin already has page query var which conflicts with your menu slug page=settings&submenu=page2.

I have updated the code.

add_menu_page( 'Main Menu', 'Main Menu Titlw', $min_access_cap, 'main-main', array($this, 'main_menu'), $icon_url, 999 );

add_submenu_page( 'main-menu', sprintf( __( '%1$s ‹ %2$s', 'main-menu' ), $title['page_title'], 'Submenu' ), $title['admin_menu_title'], $min_access_cap, 'submenu/slug', array($this, 'sub_menu') );


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.