我在header.php
文件中遇到此问题。
解析错误:语法错误,第187行
header.php
中意外的文件结尾
以下是代码,任何人都可以告诉我语法缺失在哪里。
<?php
if ( has_post_thumbnail() ) {
// check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail("featured", array("class" => "alignleft"));
?>
答案 0 :(得分:0)
您忘记了结束}
。
<?php
if (has_post_thumbnail()) {
the_post_thumbnail("featured", array(
"class" => "alignleft"
));
}
?>
答案 1 :(得分:0)
缺少}
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail("featured", array("class" => "alignleft"));
}
endwhile;
endif;
}
?>
答案 2 :(得分:0)
在你的档案中,有两个大括号丢失。
<?php if(is_front_page()){ ?> // one closing brace `}` missing for this if condition. **give spaces here**...
if ( has_post_thumbnail() ) { // one closing brace `}` for this if condition
因此,在页面的末尾,您必须添加两个结束括号。像这样更新您的代码:
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail("featured", array("class" => "alignleft"));
}
}
?>
query_posts(array("category_name" => "Home Slider" , "post_per_page" => -1, "showposts" => -1 , "post_type" => "post"));
if(have_posts()): endif; /// add here endif;
while(have_posts()): the_post(); endwhile; /// add here endwhile;