Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Custom Plugin new page WordPress

  • SOLVED

How do I add a new plugin menu page...as in an internal page on a custom plugin. But I dont want it to show up in the menu items list:

I already know this adds a menu item...but I want the page this links to...to have other pages on it.


add_menu_page('Model Management', 'Models', 'manage_options', 'models-mainmenu', 'models_home','');
add_action( "admin_print_scripts-$toplevel", 'ozh_loadjs_admin_head' );

Answers (2)

2011-10-29

Luis Abarca answers:

You can add some extra parameters to your current pages, and with a if show a different content


if ( isset($_GET['id']) ) {
include 'second_page.php';
} else {
include 'first_page.php';
}


You can also add a submenu without a parent


add_menu_page('Hotels', 'Hotels', 'edit_pages', 'hotels', 'hotels_menu_manager');
add_submenu_page('', 'Rates', 'Rates', 'edit_pages', 'hotel_rates', 'hotel_menu_manager'); // no parent


function gre_show_menu()
{
switch ($_GET['page']) {
case 'hotel':
include 'hotel-screen.php';
break;

case 'hotel_rates':
include 'hotel-rates-screen.php';
break;
}
}


bigbrer comments:

Yep Thats what I was looking for...adding a submenu with no parent. Nice.
How do I say this is the answer?


Luis Abarca comments:

Im glad it helps, just vote for me amigo, Saludos !


bigbrer comments:

I think my account is too new. They said I cant vote.


Luis Abarca comments:

Hi Amigo, is to early to vote, because your question is still active, but you can vote on Tuesday

2011-10-29

rizaljohn answers:

You may try this function:

add_action('admin_menu', 'disabled_my_menu');

function disabled_my_menu(){
global $menu, $submenu;

foreach ($menu as $index => $item) {
if (!empty($submenu[$item[2]]))
foreach ($submenu[$item[2]] as $subindex => $subitem)
if (in_array($subitem[2], 'models-mainmenu'))
unset($submenu[$item[2]][$subindex]);
}

}