为了账号安全,请及时绑定邮箱和手机立即绑定

Wordpress 函数 wp_get_attatchment_url 不起作用

Wordpress 函数 wp_get_attatchment_url 不起作用

PHP
慕娘9325324 2021-10-15 16:29:10
我添加了这个自定义函数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();

}


查看完整回答
反对 回复 2021-10-15
?
MMTTMM

TA贡献1869条经验 获得超4个赞

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


查看完整回答
反对 回复 2021-10-15
  • 2 回答
  • 0 关注
  • 152 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信