WP_Customize_Color_Control
采用3个参数:
/**
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id Control ID.
* @param array $args Optional. Arguments to override class property defaults.
*/
原始代码的问题是您传递了相同的控件ID(
link_color
) 到两个单独的实例。因此,最近添加的控件将使用相同的控件ID踩在前一个控件上。请确保为控件提供唯一的ID。
下面是修改后的代码,每个颜色控件都有唯一的控件ID:
add_action( \'customize_register\', \'main_salvio_customizer\' );
function main_salvio_customizer( $wp_customize ) {
$wp_customize->add_section( \'personalize-color-page\', array(
\'title\' => __( \'Visible Section Name\', \'text-domain\' ),
\'priority\' => 30,
) );
$wp_customize->add_setting( \'page-title-section\', array(
\'default\' => \'#3c93bd\',
\'transport\' => \'postMessage\',
) );
$wp_customize->add_setting( \'page-title-section-text-color\' , array(
\'default\' => \'#000000\',
\'transport\' => \'postMessage\',
) );
// Control ID page_text_color
$wp_customize->add_control(
new WP_Customize_Color_Control( $wp_customize, \'page_text_color\', array(
\'label\' => __( \'Page Text Color\', \'text-domain\' ),
\'settings\' => \'page-title-section-text-color\',
\'section\' => \'personalize-color-page\',
) )
);
// Control ID page_title_color
$wp_customize->add_control(
new WP_Customize_Color_Control( $wp_customize, \'page_title_color\', array(
\'label\' => __( \'Page Title Control\', \'text-domain\' ),
\'settings\' => \'page-title-section\',
\'section\' => \'personalize-color-page\',
) )
);
}