我添加了這個自定義函數functions.php 來添加圖像。// Provider Imagefunction header($wp_customize){ $wp_customize->add_setting('header-image'); $wp_customize->add_control(new WP_Customize_Cropped_Image_Control($wp_customize, 'header-image', array( 'label' => 'Add Image', 'section' => 'header-section', 'settings' => 'header-image', 'width' => 426, 'height' => 642 )));}add_action('customize_register','header');然后我回聲<img src="<?php echo wp_get_attatchment_url(get_theme_mod('header-image')) ?>">定制領域的實地工作。但頁面正在加載。
2 回答

慕雪6442864
TA貢獻1812條經驗 獲得超5個贊
首先,使用這個函數獲取header Image URL
function get_header_image() {
$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
if ( 'remove-header' == $url ) {
return false;
}
if ( is_random_header_image() ) {
$url = get_random_header_image();
}
- 2 回答
- 0 關注
- 178 瀏覽
添加回答
舉報
0/150
提交
取消