对于我正在构建的插件,我在admin中的自定义主菜单项中添加了一个子菜单作为子菜单。子菜单页是edit-tags.php
页这将按预期显示在主菜单项下。单击此子菜单项时,用户将进入正确的页面,但主菜单项会向下折叠,隐藏当前打开的子菜单项。
我最初的感觉是父slug属性是错误的,但我添加的其他子菜单使用相同的父slug属性,并且它们工作正常。很明显,我在add_submenu_page()
函数,但我不知道是什么。
下面是我注册子菜单的方式:
$this->plugin_screen_dashboard = add_submenu_page(
$this->plugin_slug, // Parent slug
__( \'Subscriber Lists\', $this->plugin_slug ), // Page title
__( \'Subscriber Lists\', $this->plugin_slug ), // Menu title
\'manage_options\', // Capability
\'edit-tags.php?taxonomy=subscriber_list&post_type=subscriber\' // Menu slug
);
--Edit--
以下是我注册主菜单项的方式:$this->plugin_screen_hook_suffix = add_menu_page(
__( \'My Plugin\', $this->plugin_slug ), // Page title
__( \'My Plugin\', $this->plugin_slug ), // Menu title
\'manage_options\', // Capability
$this->plugin_slug, // Menu slug
array( $this, \'display_plugin_admin_page\' ), // Function
\'dashicons-plus-alt\' // Icon url
);