我添加了这个自定义函数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')) ?>">自定义中的现场工作。但是页面正在加载。
发布于 2019-07-18 17:33:59
wp_get_attatchment_url看起来像是输入错误,看起来正确的名称是wp_get_attachment_url。
发布于 2019-07-18 17:17:34
首先,使用此函数获取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();
}https://stackoverflow.com/questions/57091002
复制相似问题