解析错误:语法错误,第187行的header.php中的文件意外结束

时间:2015-12-04 05:13:49

标签: php

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

3 个答案:

答案 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;