我想知道如何使用多个图像上传in the same section 在里面theme customizer.
功能是new WP_Customize_Image_Control
. 当您尝试获取已上载图像的路径时,它将仅从您创建的第一个WP\\u Customize\\u image\\u控件中提供。其他人就是不工作。
代码如下:
$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\'
)
)
);
然后我尝试使用
$first_image = get_theme_mod(\'first-img-upload\');
$second_image = get_theme_mod(\'second-img-upload\');
echo $first_image;
echo $second_image;
从这里我只得到第一个链接,但第二个链接是空的。
谢谢你的帮助。