Skip to content

Instantly share code, notes, and snippets.

@ibrokemywp
Last active July 6, 2018 11:50
Show Gist options
  • Save ibrokemywp/a6e39b0bbcfdf46b2f84 to your computer and use it in GitHub Desktop.
Save ibrokemywp/a6e39b0bbcfdf46b2f84 to your computer and use it in GitHub Desktop.
Adding a top-level admin page and sub-menu page.
// Create a top-level page with the slug `myplugin-parent`
add_menu_page(
__( 'My Plugin', 'my-plugin' ), // page title
__( 'MyPlugin-Parent', 'my-plugin' ), // menu title
'manage_options',
'myplugin-parent', // page slug
'myplugin_callback',
);
// Create a sub-page under the parent page
add_submenu_page(
'myplugin-parent', // matches page slug above
__( 'My Plugin Sub-Page', 'my-plugin' ),
__( 'SubPage', 'my-plugin' ),
'manage_options',
'myplugin-subpage', // page slug
'myplugin-subpage-callback',
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment