|
添加主菜单
主菜单添加函数
- add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
复制代码
参数解释:
$page_title: (字符串,必须)菜单页面标题,即显示在标题栏的标题
$menu_title: (字符串,必须)菜单标题,即菜单显示的问题
$capability:(字符串,必须)权限,即向哪些用户显示此菜单
$menu_slug:(字符串,必须)显示在uri地址栏里的页面名称,默认可为空,类似?page=custompage
$function:回调方法的名称
$icon_url:(可选)菜单图标url
$position:(可选)菜单显示顺序
添加子菜单到系统菜单
添加子菜单函数
- add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );
复制代码
参数解释:
$parent_slug:父菜单名称,必选。
$page_title: (字符串,必须)菜单页面标题,即显示在标题栏的标题
$menu_title: (字符串,必须)菜单标题,即菜单显示的问题
$capability:(字符串,必须)权限,即向哪些用户显示此菜单
$menu_slug:(字符串,必须)显示在uri地址栏里的页面名称,默认可为空,类似?page=custompage
$function:回调方法的名称
使用方法示例:
- add_submenu_page( 'index.php', … ); //在仪表盘添加子菜单
- add_submenu_page( 'edit.php', … ); //在文章处添加子菜单
- add_submenu_page( 'upload.php', … ); //在媒体处添加子菜单
- add_submenu_page( 'link-manager.php', … ); //在链接处添加子菜单
- add_submenu_page( 'edit.php?post_type=page', … ); //在页面处添加子菜单
- add_submenu_page( 'edit-comments.php', … ); //在评论处添加子菜单
- add_submenu_page('edit.php?post_type=your_post_type',…) //在你自定义文章类型处添加子菜单
- add_submenu_page( 'themes.php', … ); //在外观处添加子菜单
- add_submenu_page( 'plugins.php', … ); //在插件处添加子菜单
- add_submenu_page( 'users.php', … ); //在用户处添加子菜单
- add_submenu_page( 'tools.php', … ); //在工具处添加子菜单
- add_submenu_page( 'options-general.php', … ); //在设置处添加子菜单
复制代码
除此之外,还有另一种方法添加子菜单
- add_dashboard_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“仪表盘”
- add_users_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“用户”
- add_plugins_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“插件”
- add_comments_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“评论”
- add_media_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“媒体”
- add_posts_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“日志”
- add_pages_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“页面”
- add_theme_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“外观”
- add_options_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“设置”
- add_links_page($page_title, $menu_title, $capability, $menu_slug, $function); //增加子菜单到“链接”
复制代码
|
|