嗨,这是我的代码。
add_menu_page(\'Titlemenu\', \'Titlemenu\', \'read\', \'a-functions\', array(&$this,\'namefunctions1\'));
add_submenu_page(\'a-functions\', \'title1submenu\', \'title1submenu\', \'read\', \'a-functions\', array(&$this,\'namefunctions1\'));
add_submenu_page(\'a-functions\', \'title2submenu\', \'title2submenu\', \'read\', \'a-functions2\', array(&$this,\'namefunctions2\'));
我想在用户单击第一个子菜单时插入文件下载。
这是将子菜单连接到要显示的页面的经典功能。
function namefunctions1(){
<div class="wrap">
<?php
include_once(dirname( __FILE__ ) . "/file.htm");
?>
</div>
谢谢你的帮助
SO网友:Quang Hoang
You can try this.
add_action( \'admin_menu\', \'register_my_custom_menu_page\' );
function register_my_custom_menu_page() {
add_menu_page(
\'My Custom Page\',
\'My Custom Page\',
\'manage_options\',
\'my-top-level-slug\',
\'\',
\'dashicons-menu\',
6
);
add_submenu_page( \'my-top-level-slug\', \'My Custom Page\', \'My Custom Page\',
\'manage_options\', \'my-top-level-slug\', \'custom_subpage_first\');
add_submenu_page( \'my-top-level-slug\', \'My Custom Submenu Page 1\', \'My Custom
Submenu Page\',\'manage_options\', \'my-secondary-slug\', \'custom_subpage_second\');
}
function custom_subpage_first() {
?>
<div class="wrap">
<?php include_once(dirname( __FILE__ ) . "/file.htm");?>
</div>
<?php
}
function custom_subpage_second() {
?>
<div class="wrap">
/*Second subpage content */
</div>
<?php
}