Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i am trying to figure out how to use more that one image upload in the same section in theme customizer.

the function is new WP_Customize_Image_Control. when you try to get the path of the image you have uploaded it will give you only from the first WP_Customize_Image_Control you have created. the others just not working.

this is the code:

$wp_customize->add_section(
    'head_section',
    array(
        'title' => 'Head',
        'description' => 'head section.',
        'priority' => 55,
    )
);

$wp_customize->add_setting( 'img-upload' );

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'first-img-upload',
        array(
            'label' => 'first image Upload',
            'section' => 'head_section',
            'settings' => 'img-upload'
        )
    )
);

$wp_customize->add_setting( 'img-upload' );

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'second-img-upload',
        array(
            'label' => 'second image Upload',
            'section' => 'head_section',
            'settings' => 'img-upload'
        )
    )
);

then i try to get the link to the image by using

$first_image = get_theme_mod('first-img-upload');
$second_image = get_theme_mod('second-img-upload');
echo $first_image;
echo $second_image;

from here i just get the first link but the secend is empty.

thanks for help.

share|improve this question
    
Can you edit your question to include your customizer code? –  sabreuse Oct 2 '13 at 19:59
    
Hello @sabreuse i have update my quasion and add the code from Customizer. so when i try to get the url from the first and the secend image i just get only from the first upload. –  need-help Oct 5 '13 at 5:41
    
You're trying to assign two different settings to the same ID. Try it with $wp_customize->add_setting( 'first-img-upload' ); and $wp_customize->add_setting( 'second-img-upload' ); –  sabreuse Oct 6 '13 at 20:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.