add_action( \'customize_register\', \'theme_customize_register\' );
/**
* Register individual settings through customizer\'s API.
*
* @param WP_Customize_Manager $wp_customize Customizer reference.
*/
function theme_customize_register( $wp_customize ) {
// You can first start by adding a section
$wp_customize->add_section(
\'theme_options\',
array(
\'title\' => __( \'Title of your section\', \'domain\' ),
\'capability\' => \'edit_theme_options\',
\'description\' => __( \'Some description\', \'domain\' ),
\'priority\' => 160,
)
);
$wp_customize->add_setting(
\'field_name\',
array(
\'type\' => \'textarea\',
\'sanitize_callback\' => \'theme_sanitize_text\', // You can sanitize the text afterwards through this function
\'capability\' => \'edit_theme_options\',
)
);
}
在
API docs 您还可以找到可以使用的其他字段以及如何修改这些字段。
要访问您的设置,您可以使用
get_theme_mod(\'field_name\');
确保将其添加到插件或子主题。