WordPress.org

Forums

WP_Customize_Background_Image_Control not working (2 posts)

  1. Prelevic Milos
    Member
    Posted 2 years ago #

    Hello guys,
    I am having trouble using this class WP_Customize_Background_Image_Control in theme customizer.

    What I want to do is add a background image that user can choose. But when try to add that field it's not working.
    But when I use WP_Customize_Color_Control instead of WP_Customize_Background_Image_Control it is working ok, I am getting field for changing color.

    Code is at the bottom.
    Thank you

    add_action ('admin_menu', 'themedemo_admin');
    function themedemo_admin() {
        // add the Customize link to the admin menu
        add_theme_page( 'Customize', 'Customize', 'edit_theme_options', 'customize.php' );
    }
    
    add_action('customize_register', 'theme_customize');
    function theme_customize($wp_customize) {
    
        $wp_customize->add_section( 'site_colors', array(
            'title'          => 'Colors',
            'priority'       => 35,
        ) );
    
        $wp_customize->add_setting( 'header_color', array(
    
        ) );
    
        $wp_customize->add_control(
    	new WP_Customize_Background_Image_Control(
    	$wp_customize,
    	'control_id',
    	array(
    		'label'      => __( 'Header Color', 'mytheme' ),
    		'section'    => 'site_colors',
    		'settings'   => 'header_color',
    
    	) )
    );
    
        $wp_customize->get_setting( 'header_color' )->transport = 'postMessage';
    
    }
  2. Bilal Shahid
    Member
    Posted 2 years ago #

    WP_Customize_Background_Image_Control and WP_Customize_Header_Image_Control are not working for me either. You better use WP_Customize_Image_Control class instead.

Topic Closed

This topic has been closed to new replies.

About this Topic