5

I am making a plugin and I have a bunch of different data types that I am creating edit pages for. I'd rather not have to create a separate function to add each one to the admin menus, since they're all using the same function to display their edit page. I have tried:

`add_submenu_page('upload_manage', "Programs", "Programs", 'manage_options', 'manage-data&type=program', "manage_data");`

(note the &type=program -- that's what I want to work). It adds the correct link that I was trying for to the admin submenu, but when I click the menu item, I get kicked out to the dashboard with the &C=1 URL. Is there any way to do this? Or am I going to have to create 7 different functions that all call the same function to display the edit page.. i.e. manage_programs manage_schedule manage_otherstuff etc...?

1 Answer 1

5

Your menu slug (5th parameter) can't be the same across multiple pages, and it obviously can't have an & in it, but you can have all the pages you want call the same callback function (the last param).

add_submenu_page('upload_manage', "Programs", "Programs", 'manage_options', 'manage-programs', "manage_data");
add_submenu_page('upload_manage', "Schedule", "Schedule", 'manage_options', 'manage-schedule', "manage_data");

Then in the manage_data function, check the value of $_GET['page'] for the slug and act accordingly.

0

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.