• I’ve noticed that the Select list option in the WP Customizer doesn’t seem to want to put the default option in, and another quirky thing.

    This is my customizer code:

    $wp_customize->add_setting( 'showcase_bg', array(
    		'default'        => 'Background 1',
    	) );
    	$wp_customize->add_control( 'showcase_bg', array(
        'label'   => 'Showcase Background',
        'section' => 'header_image',
        'type'    => 'select',
    	'priority' => '2',
        'choices'    => array(
            'showcase-bg1.jpg' => 'Background 1',
            'showcase-bg2.jpg' => 'Background 2',
            'showcase-bg3.jpg' => 'Background 3',
            ),
    	) );

    Then this is my code (just the customizer part) in the header file that is part of an inline background style:

    <?php echo get_theme_mod( 'showcase_bg', 'showcase-bg1.jpg' ); ?>

    Now here are the quirky things that are happening:

    The default “showcase-bg1.jpg” is not going into the inline style for the background image file of my showcase container, “Background 1” is showing (which becomes a broken image).

    The other thing is that based on a guideline on github for a select list, it shows to add ‘type’ => ‘option’; to the “Add Setting”. But doing this renders the select function as non-functional but works if I take that line out from the Add Setting.

    It also shows to add the actual value in the Add Setting “Default” line. In my case, it would be showcase-bg1.jpg. But that doesn’t work unless I change that to “Background 1”.

    Hope I didn’t make this confusing, but has anyone been successful in getting a select list of options to work properly?

    With my current setup, the select list in the customizer shows the options, but the field is blank…no option is showing. I have to select from the list to make it work. In other words, when the theme is installed, there is no default background image showing because in the source code, the background image file is showing as: ..images/backgrounds/Background 1

  • The topic ‘API Customizer Not working for Select’ is closed to new replies.