您正在搜索的内容是一个子菜单页。尝试以下操作:
add_submenu_page( \'my-top-level-slug\',
\'My Custom Submenu Page\',
\'My Custom Submenu Page\',
\'manage_options\',
\'my-secondary-slug\'
);
您可以找到更多信息
here代码示例:
function my_plugins() {
add_menu_page(
\'My Plugin\',
\'My Plugin\',
\'manage_options\',
\'visitor-counter-by-funcion\', //THIS IS THE SLUG YOU NEED TO USE IN YOUR SUBMENU ITEMS
\'my_custom_menu_page\',
\'dashicons-chart-bar\'
);
add_submenu_page(
\'visitor-counter-by-funcion\', //THIS IS THE SLUG OF YOUR PARENT MENU PAGE
\'My Custom Submenu Page\',
\'My Custom Submenu Page\',
\'manage_options\',
\'my-secondary-slug\',
\'my_custom_sub_menu_page\'
);
}
add_action(\'admin_menu\', \'my_plugins\');
/**
* Display a custom menu page
*/
function my_custom_menu_page() {
esc_html_e(\'Admin Page Test\', \'textdomain\');
}
/**
* Display callback for the submenu page.
*/
function my_custom_sub_menu_page() {
?>
<div class="wrap">
<h1><?php _e(\'My Custom Submenu Page\', \'textdomain\'); ?></h1>
<p><?php _e(\'My Custom Submenu Page\', \'textdomain\'); ?></p>
</div>
<?php
}
看起来是这样的: