分析错误:语法错误,在header.php的第187行出现意外的文件结尾


Parse error: syntax error, unexpected end of file in header.php on line 187

我在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"));                        
?>

您忘记了关闭}

<?php
if (has_post_thumbnail()) {
    the_post_thumbnail("featured", array(
        "class" => "alignleft"
    ));
}
?>

缺少}

<?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;
                   }
                       ?>

文件中缺少两个大括号。

<?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;