我正在使用以下代码在wordpress中创建管理菜单:
add_menu_page(
"Deliverables",
"Deliverables",
"manage_options",
"deliverables",
"deliverable_create_deliverables_page"
);
add_submenu_page(
'deliverables',
'Review Submissions',
'Review Submissions',
'manage_options',
'manage_deliverables',
'deliverable_create_review_page'
);
这导致菜单具有以下结构:
+ Deliverables
+-- Deliverables
+-- Review Submissions
即。将有一个顶级菜单,第一个子菜单项的名称将与顶级菜单名称相同。如何确保命名所有子菜单项?我希望菜单看起来像这样:
+ Deliverables
+-- Manage Deliverables
+-- Review Submissions
答案 0 :(得分:1)
这可以通过从add_menu_page
删除回调函数并将该回调放在add_submenu_page
的顶级页面来完成。
add_menu_page(
"Deliverables",
"Deliverables",
"manage_options",
"deliverables"
);
add_submenu_page(
'deliverables',
'Manage Deliverables',
'Manage Deliverables',
'manage_options',
'deliverables',
'deliverable_create_deliverables_page'
);
add_submenu_page(
'deliverables',
'Review Submissions',
'Review Submissions',
'manage_options',
'manage_deliverables',
'deliverable_create_review_page'
);