I am creating a plugin for a custom admin menu based in the admin area.
My wordpress template is consisted of 5 pages with different templates and some custom variables that the end user would be allowed to edit with a custom role I have assigned to him, eg. grunt. The reason I am doing this is so that the user could have the minimum knowledge of interacting with the page admin. For example, I have a page with 6 custom fields that define how the template should be shown, while in another page these field variables change to alter the display effect.
So in my admin menu I would have:
Site Management
- Page 1 Admin -> This makes a carousel with 2 items max
- Page 2 Admin -> This is a plain text page
- Page 3 Admin
- Page 4 Admin -> This is a carousel with 4 items max
- Page 5 Admin
And so on.
Since my menu is the same as the pages shown + Homepage link, I have used wp_get_nav_menu_items()
function to get those menus. But now I am in a dilemma, trying to access every page's post to edit.
Here is how I list the pages on my admin menu:
$options = get_nav_menu_locations();
$menu_items = wp_get_nav_menu_items($options['main_nav']);
$i = 0;
foreach ((array) $menu_items as $key => $v):
$post = get_post($v->object_id);
setup_postdata($post);
add_submenu_page('theme_admin2', 'Administration', $v->title, 'edit_posts', 'theme_admin_'.$v->object_id, array(&$this, 'display_page_test'));
endforeach;
Each menu item is a submenu page at the moment. How can I pass the $v->object_id variable to the display_page_test function of my plugin class so that I would differentiate my output as well?
UPDATE
I am referring to creating an admin menu using the public menu items as subitems (to the admin). Once a user clicks the subitem it will be an edit screen for the page: title, body and image. This is the only view that the customer will see + profile. I've created that page, but I cannot send the object id of each menu to the callback function that creates the submenu pages.