2014-05-25 76 views
0

我的single.php文件没有错误之前我添加以下代码:基于范畴内语法错误,在single.php中意外的文件结尾文件

<?php $orig_post = $post; 
       global $post; 
       $tags = wp_get_post_tags($post->ID); 
       if ($tags) { 
       $tag_ids = array(); 
       foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; 
       $args=array(
       'tag__in' => $tag_ids, 
       'post__not_in' => array($post->ID), 
       'posts_per_page'=>10, // Number of related posts that will be displayed. 
       'caller_get_posts'=>1, 
       'orderby'=>'rand' 
       ); 
       $my_query = new wp_query($args); 
       if($my_query->have_posts()) { 
       echo '<div id="related_posts" class="clear"><h3>Related Posts</h3><ul>'; 
       while($my_query->have_posts()) { 
       $my_query->the_post(); ?> 
       <li> 
        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"> 
        <?php the_post_thumbnail('related-posts'); ?> 
        </a> 
        <div class="related_content"> 
        <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> 
        </div> 
       </li> 
       <?php 
       }; 
echo '</ul></div>'; ?> 

,一段代码来获得相关文章单一的文件,我发现在这里: http://www.webadvice.osvojito.com/wordpress-related-posts-without-plugin-with-thumbnails/

当我添加这个,我得到这个错误:“语法错误,意外的文件结尾”

我检查了我的代码语法几次,什么也没有丢失!

回答

2

您的代码缺少2 }

代码的最后几行应该是:的

   <?php 
       } 
       } 
       } 
echo '</ul></div>'; 

?> 

代替:

   <?php 
       }; 
echo '</ul></div>'; ?> 
+0

哦,我的上帝。非常业余的我,我是盲目的没有看到他们:|非常感谢你 –

+0

容易错过wordpres模板。看看Sublime Text格式的代码:http://pastebin.com/pAfMUmYp – Filype

+0

你缺少'?>'和代码结束:D btw,感谢它 –

相关问题