这段代码用于显示相关帖子并驻留在我的包含文件夹中.
我最近从Mac上的本地开发环境(使用MAMP)切换到使用WAMP的Windows.
突然,此错误发生在此代码块中.它不会发生在我的本地Mac环境中,也不会在实时测试时发生.
解析错误:语法错误,意外'endif'(T_ENDIF)
该错误明确指向倒数第二个endif.如果我删除它同样的错误被抛出指向endif代码中的最后一个.
有任何想法吗?我尝试删除两个指定的endif;语句,它会抛出以下错误:
解析错误:语法错误,意外的文件结束
<?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; ?>
Run Code Online (Sandbox Code Playgroud)
Abr*_*ver 20
short_open_tag可能没有启用php.ini.更改:
<? endwhile; ?>
Run Code Online (Sandbox Code Playgroud)
至:
<?php endwhile; ?>
Run Code Online (Sandbox Code Playgroud)
你应该改变所有其它的short_open_tag = On到<?.
| 归档时间: |
|
| 查看次数: |
22101 次 |
| 最近记录: |