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…?
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).
Then in the manage_data function, check the value of $_GET[‘page’] for the slug and act accordingly.