1. 主页
  2. 文档
  3. WordPress主题制作
  4. Theme Options-Customize API -Customizer
  5. 归属2


Customizer options can be granted to users with different capabilities on a granular basis, so while most options are visible only to administrators by default, other users may access certain options if you want them to be able to. Different parts of the Customizer can also be contextual to whether they’re relevant to the front-end context that the user is previewing. For example, the core widgets functionality only shows widget areas that are displayed on the current page; other widget areas are shown when the user navigates to a page that includes them within the Customizer preview window.

This section contains an overview of the Customize API, including code examples and discussion of best practices. For more details, it is strongly recommended that developers study the core customizer code (all core files containing “customize”). This is considered the canonical, official documentation for the Customize API outside of the inline documentation within the core code.


Customizer objects:

面板Panels:Panels are containers for sections, allowing multiple sections to be grouped together.
部件Sections: Sections are UI containers for controls, to improve their organization.
设置Settings:Settings associate UI elements (controls) with settings that are saved in the database. 
控件Controls:UI elements
Customizer objects are managed by the Customize Manager object, 




To add, remove, or modify any Customizer object, and to access the Customizer Manager, use the customize_register hook:

function themeslug_customize_register( $wp_customize ) {
// Do stuff with $wp_customize, the WP_Customize_Manager object.
add_action( ‘customize_register’, ‘themeslug_customize_register’ );


theme_mod: 另一方面,主题模式是针对特定主题的。大多数主题选项应该是theme_mods。 例如,自定义CSS插件可以将自定义主题css设置注册为theme_mod,允许每个主题具有独特的一组CSS规则,而不会在切换主题然后切换时丢失CSS。

核心自定义控制Core Custom Controls



自定义控件,部分和面板(Custom Controls, Sections, and Panels)

定制界面UI标准(Customizer UI Standards)
自定义设置类型(Custom Setting Types)
默认情况下,定制程序支持将设置保存为选项或主题修改。 但是,可以轻松地覆盖此行为,以手动保存和预览WordPress数据库的wp_options表外的设置,或应用其他自定义处理。 要开始使用,请在添加设置时指定除选项或theme_mod之外的类型(您几乎可以使用任何字符串):