第一个子菜单项
-
-
我为相同的目的找到了一个非常有用的博客http://tekina.info/add-menus-submenus-wordpress-admin-panel/I found a very usefull blog for the same pupose http://tekina.info/add-menus-submenus-wordpress-admin-panel/
- 0
- 2017-09-12
- Aniket Singh
-
4 个回答
- 投票数
-
- 2012-09-27
您可以使子菜单页面的"子弹"等于顶级页面的子弹,它们将指向同一位置:
add_action('admin_menu', 'my_menu_pages'); function my_menu_pages(){ add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' ); add_submenu_page('my-menu', 'Submenu Page Title', 'Whatever You Want', 'manage_options', 'my-menu' ); add_submenu_page('my-menu', 'Submenu Page Title2', 'Whatever You Want2', 'manage_options', 'my-menu2' ); }
例如
You can make the 'slug' for the submenu page equal that of the top level page, and they'll point to the same place:
add_action('admin_menu', 'my_menu_pages'); function my_menu_pages(){ add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' ); add_submenu_page('my-menu', 'Submenu Page Title', 'Whatever You Want', 'manage_options', 'my-menu' ); add_submenu_page('my-menu', 'Submenu Page Title2', 'Whatever You Want2', 'manage_options', 'my-menu2' ); }
E.g.
-
这将导致重复的条目,因为Wordpress会自动为主页创建一个子菜单页.This would result in duplicate entries, since Wordpress automatically creates a submenu page for the main page.
- 0
- 2012-09-27
- MegaHit
-
我记得上周浏览了核心代码,并遇到了一条注释,内容类似:"如果用户尚未添加默认子菜单项".它检查是否有子菜单项指向顶层项目.如果存在,则不添加默认值.I remember skimming through the core code last week and running into a note that said something like: "Add default submenu item IF USER HASN'T ALREADY". It checks to see if there's a submenu item pointing to the top level item. If there is, it doesn't add the default.
- 5
- 2012-09-27
- Michael Lewis
-
我想在创建自定义菜单时希望显示一些表和数据,而其他选项卡则显示教程链接或某些功能帮助I want when i create custom menu i want to display some tables and data as other tabs are display a tutorial link or some function help will be appreciated
- 0
- 2016-10-23
- Aitazaz Khan
-
正是我想要的.谢谢:PExactly what I waas looking for. Thanx :P
- 0
- 2018-09-10
- Rob D. A.
-
这对我来说仍然很好...this works fine for me too still...
- 0
- 2020-04-06
- Sajjadur Rahman Sagor
-
- 2019-12-08
使父菜单项和子菜单的子段相同(第一个项),如下所示
function acutions_recent_bids_add_admin_page(){ add_menu_page('Recent Bids', 'Auction Reports', 'manage_options','wc-auction-reports','acutions_recent_bids_list','dashicons-chart-area', 56); add_submenu_page( 'wc-auction-reports', // parent slug 'Recent Bids', // page title 'Recent Bids', // menu title 'manage_options', // capability 'wc-auction-reports', // slug 'acutions_customers_spendings_list' // callback ); add_submenu_page( 'wc-auction-reports', // parent slug 'Customer Spending', // page title 'Customer Spending', // menu title 'manage_options', // capability 'wc-acutions-customers-spendings', // slug 'acutions_customers_spendings_list' // callback ); add_submenu_page( 'wc-auction-reports', // parent slug 'Customer Bids', // page title 'Customer Bids', // menu title 'manage_options', // capability 'wc-acutions-customers-bids', // slug 'acutions_customers_bids_list' // callback ); } add_action('admin_menu','acutions_recent_bids_add_admin_page');
make the slug of parent menu item and sub menu same (first one item) like below
function acutions_recent_bids_add_admin_page(){ add_menu_page('Recent Bids', 'Auction Reports', 'manage_options','wc-auction-reports','acutions_recent_bids_list','dashicons-chart-area', 56); add_submenu_page( 'wc-auction-reports', // parent slug 'Recent Bids', // page title 'Recent Bids', // menu title 'manage_options', // capability 'wc-auction-reports', // slug 'acutions_customers_spendings_list' // callback ); add_submenu_page( 'wc-auction-reports', // parent slug 'Customer Spending', // page title 'Customer Spending', // menu title 'manage_options', // capability 'wc-acutions-customers-spendings', // slug 'acutions_customers_spendings_list' // callback ); add_submenu_page( 'wc-auction-reports', // parent slug 'Customer Bids', // page title 'Customer Bids', // menu title 'manage_options', // capability 'wc-acutions-customers-bids', // slug 'acutions_customers_bids_list' // callback ); } add_action('admin_menu','acutions_recent_bids_add_admin_page');
-
-
骇客骇客.使用API!Hackedy hack. Use the API!
- 7
- 2016-04-12
- Richard Sweeney
-
-
- 2016-09-29
add_submenu_page( 'tut_theme_settings', // parent slug 'Front Page Elements 2', // page title 'Front Page 2', // menu title 'manage_options', // capability 'tut_theme_settings2', // slug 'theme_front_page_settings' // callback );
如果第一个子菜单的名称不同,则会创建相同的父级和第一个子级,并调用相同的功能
add_submenu_page( 'tut_theme_settings', // parent slug 'Front Page Elements 2', // page title 'Front Page 2', // menu title 'manage_options', // capability 'tut_theme_settings2', // slug 'theme_front_page_settings' // callback );
if different name of first sub-menu create same slug of parent and first child and call same function
-
与接受的答案有何不同?以及应该采取何种行动.How is it different from the accepted answer? And to which action this should be hooked.
- 2
- 2016-09-29
- bravokeyl
add_menu_page
文档表示将菜单标题作为第二个参数:稍后通过主页面
add_submenu_page
添加更多页面时成为子菜单中的第一项:但是,我希望列表中的第一项具有不同的名称(但仍指向同一页面),即Wordpress本身的方式:
我该如何在插件中完成?