When you add a page with add_submenu_page()
, the url should be something like:
wp-admin/admin.php?page=<your_page_handle>
Your page is actually loaded from admin.php
(typically). You can add parameters to your links by appending something like &id=3
and then have your main plugin page-loading logic determine which file to include based on the parameter.
For instance
if (isset($_GET['id']) && ((int) $_GET['id']) == 3) {
include 'second_page.php';
} else {
include 'first_page.php';
}
Edit:
I found a trick that may be easier for you, though I haven't thoroughly tested it. Let's say that you have two pages: my_one
and my_two
. Just call add_submenu_page
twice, and set the second page's parent as the first page. This will cause Wordpress to not add a link to the navigation bar, but you can still access your page by navigating to admin.php?page=my_two
.
Example:
add_submenu_page(
'my_toplevel_link'
, 'Page Title'
, 'Link Name'
, 'administrator'
, 'my_one' // here's the page handle for page one
, 'my_one_callback'
);
add_submenu_page(
'my_one' // set the parent to your first page and it wont appear
, 'Page Title'
, 'Link Name' // unused
, 'administrator'
, 'my_two'
, 'my_two_callback'
);