我試圖在WordPress定製器中設置背景圖像。我可以上傳圖片並在Customizer中預覽,但在保存之後,它不會出現在實況網站上。未在WordPress定製器中保存背景圖像
我在customizer.php文件下面的代碼:
$wp_customize->add_setting('section_1_background_image', array(
'default' => get_template_directory_uri() . '/images/default.jpg',
'transport' => 'postMessage',
));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'section_1_background_image_control', array(
'label' => __('Background Image','minisite'),
'settings' => 'section_1_background_image',
'section' => 'section_1',
'priority' => 10,
)));
,並在我的customizer.js相應的代碼文件
wp.customize('section_1_background_image', function(value) {
value.bind(function(newval) {
$('#wrapper-1').css('background-image', newval);
});
});
此相同的設置工作正常,背景顏色,但我相信它必須處理「url」需要在背景圖像文件名前面的css中輸出,而不是這樣做。
我也嘗試沒有成功如下:
wp.customize('section_1_background_image', function(value) {
value.bind(function(newval) {
$('#wrapper-1').css('background-image', 'url("' + newval + '")');
});
});
我缺少的東西?
我認爲這是爲了更多的自定義頁面背景圖像,但我在整個主題中使用了幾次。 –