Add sub menu page to the Settings menu.

add_options_page() 描述



add_options_page() 用法



(string) (必填) The text to be displayed in the title tags of the page when the menu is selected

默认值: None


(string) (必填) The text to be used for the menu

默认值: None


(string) (必填) The capability required for this menu to be displayed to the user.

默认值: None


(string) (必填) The slug name to refer to this menu by (should be unique for this menu).

默认值: None


(callback) (可选) The function to be called to output the content for this page.

默认值: ' '

add_options_page() 参数



The resulting page's hook_suffix (What add_submenu_page() returns)

add_options_page() 返回值


Typical usage occurs in a function registered with the 'admin_menu' hook (see Adding Administration Menus):

Object Oriented options page helper / view:

add_options_page() 示例


  • This function is a simple wrapper for a call to add_submenu_page(), passing the received arguments and specifying 'options-general.php' as the $parent_slug argument. This means the new options page will be added as a sub menu to the Settings menu.
  • The $capability parameter is used to determine whether or not the page is included in the menu based on the Roles and Capabilities) of the current user.
  • The function handling the output of the options page should also verify the user's capabilities.
  • If there are spaces in the slug, then these will be stripped out when the URL is generated. This will result in an error message telling you that you do not have sufficient permissions to view the page.

add_options_page() 注意


add_options_page() 函数的代码位于 wp-admin/includes/plugin.php.

add_options_page() 源文件