我在我的 wordpress 主题中有这段 php 代码,其中帖子的标签将被获取并以指定的不同颜色显示。但我得到的只是一个解析错误。如果有人可以提供帮助,我将不胜感激。
这是代码
<div class="category-light">
<?php $recent = new WP_Query(array( 'cat' => $categories, 'posts_per_page' => $number )); while($recent->have_posts()) : $recent->the_post();?>
<div class="cat-light-top">
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?>
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail('post-thumb'); ?></a>
<?php } ?>
<style type="text/css">
.poli {
color: #6868eb;
float: left;
font: 13px/10px oswald,helvetica, sans-serif;
margin-bottom: 5px;
padding-bottom: 5px;
text-transform: uppercase;
}
</style>
<?php
if ($all_the_tags);
$all_the_tags = get_the_tags();
foreach($all_the_tags as $this_tag) {
if ($this_tag->name == "politics" ) {
?>
<span class="poli" style="color:#5e6de0;">politics</span>
<?php } else if ($this_tag->name == "front" ) { ?>
<span class="poli" style="color:#a33030;">front</span>
<?php } else {
// it's neither, do nothing
?>
<!-- not tagged as one or the other -->
<?
}
}
}
?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?> </a></h2>
</div><!--cat-light-top-->
<?php endwhile; ?>
</div><!--category-light-->
解析错误:语法错误,C:\wamp\www\daily\wp-content\themes\Daily Guide\widgets\widget-catlight.php 中的意外 'endwhile' (T_ENDWHILE) 在第 96 行,第 96 行是有''的代码