duanaigua4033 2013-11-22 19:48
浏览 290
已采纳

解析错误:语法错误,WordPress主题中意外的'endif'(T_ENDIF)

This bit of code is for displaying related posts and resides in my includes folder.

I have recently switched from a local development environment on a Mac (using MAMP) to using Windows with WAMP.

Suddenly this error is occurring in this block of code. It did not occur on my local Mac environment, nor does it occur when testing live.

Parse error: syntax error, unexpected 'endif' (T_ENDIF)

The error specifically points to the second to last endif. If I remove it the same error is thrown pointing to the last endif in the code.

Any ideas? I tried removing both of the specified endif; statements and it throws the following error instead:

Parse error: syntax error, unexpected end of file

<?php  
  $orig_post = $post;  
  global $post;  
  $tags = wp_get_post_tags($post->ID);  
?>
<?php if ($tags):  ?>
<?php  
  $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'=>3, // Number of related posts to display.  
  'caller_get_posts'=>1 ,
  'post_type' => array( 'post', 'featured-wedding' )
  );  

  $my_query = new wp_query( $args );  
?>
<?php if($my_query->have_posts()): ?>  
    <aside class="related group">
      <h2>You May Also Like:</h2>
      <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>

        <a href="<? the_permalink()?>">
            <!-- thumbnail -->
            <?php the_post_thumbnail(array(175,175)); ?>
            <!-- post title -->
            <?php if ( 'featured-wedding' == get_post_type() ) : ?>
              <h1>Featured Wedding: <?php the_title(); ?></h1>
            <?php else: ?>
              <h1><?php the_title(); ?>: <?php if (function_exists('the_subheading')) { the_subheading('<span>', '</span>'); } ?></h1>
            <?php endif; ?>
        </a>    

      <? endwhile; ?>
    </aside> 
<?php endif; ?>
<?php  
  $post = $orig_post;  
  wp_reset_query();  
 ?>  

<?php endif; ?>
  • 写回答

2条回答 默认 最新

  • dousongxuan7507 2013-11-22 19:51
    关注

    short_open_tag is probably not enabled in php.ini. Change:

      <? endwhile; ?>
    

    To:

      <?php endwhile; ?>
    

    And you should change all other <? to <?php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析