您将设置定义为数组,但是,您会反复引用同一个条目slider[images]
.
$wp_customize->add_section("slider_images", array(
\'title\' => "Slider",
\'description\' => "Choose the images for the slider",
\'priority\' => \'36\',
));
$wp_customize->add_setting("slider_images", array(
\'default\' => "",
\'type\' => "option",
));
$slider_images = get_setting(\'slider_images\');
$num_images = 0;
if (is_array($slider_images) && ! empty($slider_images))
$num_images = count($slider_images);
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, "slider_images[".$num_images."]", array(
\'label\' => __("Images", "adaptive-framework"),
\'section\' => "slider",
\'settings\' => "slider_images",
)));
Note: 我没有对此进行测试,而且我以前从未使用过WP的主题定制API。当然,您需要注意删除图像,并处理剩余的图像/数组条目等。这只是一个(很可能不起作用)示例。
如果要在单个设置中存储多个条目,请使用数组(例如。,slider_images
). 然后,要定义一个特定条目,请引用特定的数组条目(例如。,slider_images[0]
).