wordpress在后台添加一级菜单以及其二级菜单
add_action('admin_menu','add_settings_menu');
function add_settings_menu() {
add_menu_page('自定义菜单标题', '自定义菜单', 'manage_options', 'my-top-level-slug');
add_submenu_page( 'my-top-level-slug', '子菜单1', '子菜单1','manage_options', 'my-top-level-slug','my_function_menu');
add_submenu_page( 'my-top-level-slug', '子菜单2', '子菜单2','manage_options', 'my-secondary-slug','my_function_submenu1');
}
function my_function_menu() {
echo "<h2>测试菜单设置1</h2>";
}
function my_function_submenu1() {
echo "<h2>测试菜单设置2</h2>";
}
参考官方文档:https://developer.wordpress.org/reference/functions/add_submenu_page/