0

I've been able to add two other color options to the default Wordpress Color Customizer section using the following:

$wp_customize->add_setting( 'understrap_hero_bgcolor', array(
    'default'           => '#ECEEEF',
    'type'              => 'color',
    'capability'        => 'edit_theme_options',
) );
$wp_customize->add_setting( 'understrap_hero_textcolor', array(
    'default'           => '#000',
    'type'              => 'color',
    'capability'        => 'edit_theme_options',
) );        
$wp_customize->add_control( 
    new WP_Customize_Color_Control( 
    $wp_customize, 
    'hero_bgcolor', 
    array(
        'label'      => __( 'Hero Background Color', 'understrap' ),
        'section'    => 'colors',
        'settings'   => 'understrap_hero_bgcolor',
    ) ) 
);
$wp_customize->add_control( 
    new WP_Customize_Color_Control( 
    $wp_customize, 
    'hero_textcolor', 
    array(
        'label'      => __( 'Hero Text Color', 'understrap' ),
        'section'    => 'colors',
        'settings'   => 'understrap_hero_textcolor',
    ) ) 
);

They load in the customizer fine, but they're not saving values in the back end, or for use in the front end using:

$hero_bgcolor = get_theme_mod( 'understrap_hero_bgcolor' );
$hero_textcolor = get_theme_mod( 'understrap_hero_textcolor' );

What do I need to do to allow extra color settings in the default Wordpress color customizer to save properly?

I'm using the Understrap theme.

Help appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.