Support » Fixing WordPress » Color Picker for Background Color

  • The code below was added to my theme customizer. It is added correctly but, when I select a color from the picker, it doesn’t update. Tried but can’t make it work. Any help appreciated. Thanks!

    // Background Color Section start
    $wp_customize->add_section( 'wp_custom_color_section_backgr', array(
    	'priority' => 10,
    	'capability' => 'edit_theme_options',
    	'theme_supports' => '',
    	'title' => __( 'Background Color Options', 'heading-color-options' ),
    	'description' => '',
    	'panel' => 'wp_custom_color_section_panel'
         ) ); 
    
    $wp_customize->add_setting(
    'link_color',
             array(
             'default'     => '#ffffff'
             )
    	               );
    
         $wp_customize->add_control(
               new WP_Customize_Color_Control(
               $wp_customize,
               'link_color',
               array(
                   'label'      => __( 'Background Color Options', 'heading-color-options' ),
                   'section'    => 'wp_custom_color_section_backgr',
                   'settings'   => 'link_color'
                           )
                       )
                   );
    //Check box on Background
    $wp_customize->add_setting('wp_custom_color_backgr_checkbox', array(
    	    	    'default'    => '',
    		    	));
    
    $wp_customize->add_control(
         new WP_Customize_Control(
    	$wp_customize,
    	'wp_custom_color_backgr_checkbox',
    	array(
    	'label'     => __('Enable Background Color', 'heading-color-options'),
    	'section'   => 'wp_custom_color_section_backgr',
    	'settings'  => 'wp_custom_color_backgr_checkbox',
    	'type'      => 'checkbox',
    		    	        )
    		    	    )
    		    	);
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @mrcangrejero,
    You can take reference from these codes:

    $wp_customize->add_setting(
        'font-color',
        array(
            'default' => '#444444',
            'sanitize_callback' => 'sanitize_hex_color',
        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Color_Control(
            $wp_customize,
            'font-color',
            array(
                'label' => __('Page/Post Title Font Color','cyclone_corporate'),
                'section' => 'colors',
                'settings' => 'font-color'
            )
        )
    );

    At worst case option, you can force main colors using Jquery calls like :

    <body id=”color”>

    <div id=”post-color”>

    text and so on..

    </div>

    and in before style.css

    {
    #color (font-style:”italic”; color:”#ccc”;)
    #post-color (color: “#fff;”) for white text color
    }

    Good luck,

    To WEN Solutions and Digico Paris:

    Not since my days back in the 80’s, when I started programing with MS-DOS, Basic, dBase III and my Tandy 1000 (with 10Mb External Hard Drive and 256K of RAM) had I met such nice people willing to help others. I really want to thank you and wish the best to both of you and yours. I’m trying to learn about PHP, mySQL, etc. but, at 66, my short memory betrays me.

    I’m going to work with your suggestions and will get back to you no matter what happens. If I don’;t get back to you in a reasonable period of time, I probably forgot to do it. Take care!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Color Picker for Background Color’ is closed to new replies.