Wanna customize Wordpress theme by adding an image section in header but error: syntax error, unexpected 'action' (T_STRING)

Wanna customize Wordpress theme by adding an image section in header but error: syntax error, unexpected 'action' (T_STRING)

#在主题功能中 //一个文件 //在标题中添加图片

function lwp_header_callout($wp_customize){
    $wp_customize->add_setting('lwp-header-callout-image');
    $wp_customize->add_control(new WP_Customize_Cropped_Image_Control($wp_customize,'lwp-header-callout-image-control',array(
    'label'=>'Image',
    'section'=>'lwp-header-callout-section',
    'setting'=>'lwp-header-callout-image',
    'width'=>1190,
    'height'=>129)));
}
add action('customize_register','lwp_header_callout');

//标题结束图片

#在主题中header //第二个文件 //开始header

<div class="nicdark_grid_12" >

            <div class="nicdark_section nicdark_height_80"></div>
            <img src="<?php echo wp_get_attachment_url(get_template_directory_uri('lwp-footer-callout-image'))?>">
<div class="nicdark_section nicdark_height_80"></div>

//结束header

在主题样式部分

//第三个文件 // 开始 Header 标注部分

.Header-callout-image{
    width:100%,
    }

//结束

您需要使用 get_theme_mod() 获取图像,因此函数如下所示:

<img src="<?php echo wp_get_attachment_url(get_theme_mod('lwp-footer-callout-image'))?>">

add action('customize_register','lwp_header_callout'); 更正为

add_action('customize_register','lwp_header_callout');