0
我在我的function.php
文件中具有以下功能;使用wp_customize在wordpress菜單中添加自定義部分以選擇圖像
function customize_images($wp_customize){
$wp_customize->add_section('customize_images_save', array(
'title' => __('Custom Image', 'themename'),
'description' => 'Select Image',
'priority' => 120,
));
$wp_customize->add_setting('image_option', array(
'default' => 'image.jpg',
'capability' => 'edit_theme_options',
'type' => 'option',
));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'image_option', array(
'label' => __('Select Image', 'themename'),
'description' => '',
'section' => 'customize_images_save',
'priority' => 10,
'settings' => 'image_option',
)));
}
這應該在我的WordPress添加自定義部分自定義菜單。
然後下面的代碼來顯示image in my home-page.php
文件;
<?php
$my_image_top = get_theme_mod('image_option', 'default.jpg');
$image_top = wp_get_attachment_image_src($my_image_top , 'full');
?>
<img src="<?php echo $image_top ?>">
不幸的是,它沒有顯示任何東西,它只是返回一個空白<img src"">
。我一直在努力尋找錯誤,有什麼幫助?