首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress函数wp_get_attatchment_url不工作

Wordpress函数wp_get_attatchment_url不工作
EN

Stack Overflow用户
提问于 2019-07-18 17:12:13
回答 2查看 52关注 0票数 0

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

代码语言:javascript
复制
// 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');

之后我会回声

代码语言:javascript
复制
<img src="<?php echo wp_get_attatchment_url(get_theme_mod('header-image')) ?>">

自定义中的现场工作。但是页面正在加载。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-07-18 17:33:59

wp_get_attatchment_url看起来像是输入错误,看起来正确的名称是wp_get_attachment_url

票数 0
EN

Stack Overflow用户

发布于 2019-07-18 17:17:34

首先,使用此函数获取header Image URL

代码语言:javascript
复制
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();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57091002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档