因此,我在定制器中有此定制部分,用于控制主页上的功能产品。所有这些都已注册,依此类推,但我遇到的问题是客户端上载我不知道如何进行更新的功能图片之一。
我正在使用的functions.php代码:
// Customiser
function themeName_customize_register( $wp_customize ) {
$wp_customize->add_setting('feature_product_one', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_setting('feature_product_two', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_setting('feature_product_three', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_setting('feature_product_four', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_section('feature_images', array(
'title' => __('Featured Products', 'themeRemax'),
'description' => __('Your 5 Feature Images on the Home-Page.'),
'priority' => 70,
'active_callback' => 'is_front_page',
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_one_control', array(
'label' => __('Feature Product #1', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_one',
)));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_two_control', array(
'label' => __('Feature Product #2', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_two',
)));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_three_control', array(
'label' => __('Feature Product #3', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_three',
)));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_four_control', array(
'label' => __('Feature Product #4', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_four',
)));
}
add_action('customize_register', 'themeName_customize_register');
我将这两个产品设置为具有相同的默认图像,但是当我进入定制器并进行更新时,Feature Product #2
它根本不会更新。
我知道我需要在<img>
标签的首页添加一些代码,但是我不知道什么:/
我有一种感觉,就是上面我做的事情很漫长,但这是我正在做的事情,如果有一种简单的方法,那么我将不胜感激您将我指向这个方向:)
感谢您的帮助
旁注:我的前page.php文件:
<div class="featureImg">
<img src="What goes here?" alt="Product 1">
<img src="What goes here?" alt="Product 1">
</div>