Adding menu in wordpress but it should not be a page
I have used add_menu_page()
which adds a menu and also creates a submenu with that name.
The syntax is:
add_menu_page($pagetitle,$menutitle,$capability,$menu_slug,$function,$icon-url,$position);
For example:
add_menu_page('ABCD','ABCD','read','r121_abcd','callMe','','4');
This creates a menu in my administration screen but it also creates a submenu with same name ABCD
.
I don't want that name for my submenu I want it as PQRST
or I don't want any page associated with that menu. And then I can add pages using add_submenu_page()
.
So there should be ABCD(Menu) -> PQRST(submenu)
. 开发者_StackOverflowNo ABCD(menu) -> ABCD(submenu)
.
I am not able to figure out that .
Try using:
add_menu_page('','ABCD','read','ABCD_slug','','','4');
add_submenu_page('ABCD_slug','PQRST','PQRST','read','ABCD_slug',array($this,'myFunction'));
remove_submenu_page('ABCD_slug', 'ABCD_slug');
worked for me.
//Format - > add_menu_page($pagetitle,$menutitle,$capability,$menu_slug,$function,$icon-url,$position);
add_menu_page('','ABCD','read','ABCD_slug','','','4');
//Format - >
add_submenu_page($parent_slug,$page_title,$menu_title,$capability,$menu_slug,$function);
add_submenu_page('ABCD_slug','PQRST','PQRST','read','ABCD_slug',array($this,'myFunction'));
This does the thing, i.e. giving the same menu_slug.
精彩评论