[英]Wanna customize Wordpress theme by adding an image section in header but error: syntax error, unexpected 'action' (T_STRING)
#In Theme Function //one file //Add image in heading #In Theme Function //one file //在标题中添加图片
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');
//End image in heading //标题中的结束图像
#In Theme header //second file //start header #In Theme 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>
//End header //结束标题
In Theme style section在主题风格部分
//third file // Start Header callout section //第三个文件 // 开始标题标注部分
.Header-callout-image{
width:100%,
}
//End //结尾
Correct add action('customize_register','lwp_header_callout');
正确
add action('customize_register','lwp_header_callout');
to到
add_action('customize_register','lwp_header_callout');
您将需要使用get_theme_mod()获取图像,因此该函数如下所示:
<img src="<?php echo wp_get_attachment_url(get_theme_mod('lwp-footer-callout-image'))?>">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.