Sorry if this has been asked before; I have been looking for a while, but couldn't find anything directly applicable. I am building my first plugin and I am trying to follow the WP best practices.

My current plugin structure looks like this:

- my-plugin
-- index.php
-- admin (folder
--- sub-menu-page.php

I am trying to keep all of my plugin pages separate as part of my organization. However, I can't seem to point my plugin's submenu link to the sub-menu-page.php file. Here's my menu code:

add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
    add_menu_page('WISE Admin', 'WISE Admin', 'manage_options', 'wise-menu', 'my_menu_output', 'dashicons-tickets', 2 );
    add_submenu_page('wise-menu', 'General Settings', 'General', 'manage_options', 'general-settings', 'general_settings' );
    add_submenu_page('wise-menu', 'Submenu Page', 'Submenu Page', 'manage_options', 'admin/sub-menu-page' );
    remove_submenu_page('wise-menu', 'wise-menu');

The submenu link takes me to /wp-admin/admin/sub-menu-page which is obviously not where I want to go.

Can I please have some advice for what I am doing wrong?

1 Answer 1


You're very close.

When you add your first submenu page you want to duplicate your initial menu page. In your second add_submenu_page you are missing the function callback for that page. Technically this parameter is optional, but it changes your url from /wp-admin/sub-menu-page to /wp-admin/admin.php?page=sub-menu-page.

Give this a shot:

add_action( 'admin_menu', 'my_menu_pages' );
function my_menu_pages() {
    add_menu_page( 'WISE Admin', 'WISE Admin', 'manage_options', 'wise-menu', 'my_menu_output', 'dashicons-tickets', 2 );
    add_submenu_page( 'wise-menu', 'General Settings', 'General', 'manage_options', 'wise-menu', 'my_menu_output' );
    add_submenu_page( 'wise-menu', 'Submenu Page', 'Submenu Page', 'manage_options', 'sub-menu-page', 'submenu_settings' );

Your Answer

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

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