Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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...?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks, I will try that out. :) –  jessica Jul 3 '11 at 14:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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