Wordpress 函数 wp_get_attatchment_url 不起作用

我添加了这个自定义函数functions.php 来添加图像。


// Provider Image

function 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')) ?>">

定制领域的实地工作。但页面正在加载。


慕娘9325324
浏览 155回答 2
2回答

慕雪6442864

首先,使用这个函数获取header Image URLfunction get_header_image() {$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );if ( 'remove-header' == $url ) {&nbsp; &nbsp; return false;}if ( is_random_header_image() ) {&nbsp; &nbsp; $url = get_random_header_image();}

MMTTMM

wp_get_attatchment_url看起来输入错误,正确的名称似乎是wp_get_attachment_url。
打开App,查看更多内容
随时随地看视频慕课网APP