Neta Meta
Neta Meta

Reputation: 4047

each plugin i make i have a issue with the add menu and submenu pages

So what i mean by the above is. I've so far made many plugins but i keep getting this issue which i don't know how to describe and that is why i cant search it on google.

What happen is in many plugin a main menu is required and under it several sub-menus that leads to different pages related to the plugin. you can click on the main menu lets say "car" and that will take you to a add car page. and there will also be a sub-menu called add car.

like: posts - when you click on posts for example it takes you to all post, but there is also a sub-menu that is called all post.

What i am having problem with is the main menu is named one thing and when hover it the first sub-menu is also called the same.

My question is:

How can i make it so that either when creating a main menu it will not automatically add a sub menu or if it does. the name will be different then the main menu.

I hope the explanation is clear - i really tried.

Here is how i define my menus:

 function my_plugin_menu() {
add_menu_page( 'add_deal', 'Add Deal', 'manage_options', 'add_deal', 'menuload_add_deal', '', '28');
add_submenu_page( 'add_deal', 'deals', 'Deals', 'manage_options', 'deals', 'menuload_deals');
add_submenu_page( 'add_deal', 'orders', 'Order', 'manage_options', 'orders', 'menuload_orders');
add_submenu_page( 'add_deal', 'gc_options', 'Options', 'manage_options', 'gc_options', 'menuload_gc_options');
}
add_action( 'admin_menu', 'my_plugin_menu' );

The above now display for me:

I would like to change it to:

Ones again i hope that makes sense.. not trying to waste anyone's time but that's why its so hard for me to find info on googble about this issue. (i don't know how to describe the problem well).

Upvotes: 0

Views: 70

Answers (1)

Neta Meta
Neta Meta

Reputation: 4047

I've found a solution incase anyone interested:

function my_plugin_menu() {
add_menu_page( 'add_product', 'Bass Nation', 'manage_options', 'bass-nation-real-shopping-cart', 'menu_load_add_product', '', '28');
add_submenu_page( 'bass-nation-real-shopping-cart', 'add_product', 'Add Product', 'manage_options', 'bass-nation-real-shopping-cart', 'menu_load_add_product');
add_submenu_page( 'bass-nation-real-shopping-cart', 'products', 'Products', 'manage_options', 'products', 'menu_load_products');
add_submenu_page( 'bass-nation-real-shopping-cart', 'orders', 'Orders', 'manage_options', 'orders', 'menu_load_orders');
add_submenu_page( 'bass-nation-real-shopping-cart', 'bnrsc_options', 'Options', 'manage_options', 'bnrsc_options', 'menu_load_options');
}
add_action( 'admin_menu', 'my_plugin_menu' );

You just name the first sub menu's slugen same as the main menu.

Hope this helps someone out there.

Upvotes: 1

Related Questions