访问此链接并阅读transporter
参数:https://codex.wordpress.org/Theme_Customization_API
这就是你要找的吗?
下面是一个示例:
<?php
add_action( \'customize_register\', \'my_customizer\' );
function my_customizer($wp_customize){
$wp_customize->add_section( \'my_section\',
array(
\'title\' => __( \'My Custom Section\', \'mytheme\' ), //Visible title of section
\'capability\' => \'edit_theme_options\', //Capability needed to tweak
)
);
$wp_customize->add_setting( \'my_setting\',
array(
\'default\' => \'option1\', //Default setting/value to save
\'type\' => \'theme_mod\', //Is this an \'option\' or a \'theme_mod\'?
\'capability\' => \'edit_theme_options\', //Optional. Special permissions for accessing this setting.
\'transport\' => \'postMessage\', //What triggers a refresh of the setting? \'refresh\' or \'postMessage\' (instant)?
)
);
$wp_customize->add_control(
\'my_control\',
array(
\'label\' => __( \'My Custom Control\', \'mytheme\' ),
\'section\' => \'my_section\',
\'settings\' => \'my_setting\',
\'type\' => \'radio\',
\'choices\' => array(
\'option1\' => \'Option 1\',
\'option2\' => \'Option 2\',
),
)
);
}