在循环中,可以使用变量进行检查,在这种情况下$i
, 因此,代码将属于:
<?php $the_query = new WP_Query( \'showposts=7&cat=113\' ); ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<strong><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></strong>
<hr size="1" color="#919191">
<?php endwhile;?>
<?php $the_query = new WP_Query( \'showposts=7&cat=113\' ); ?>
<?php $i = 0; while ($the_query->have_posts()) : $the_query->the_post();
$i++;
// First post
if ( $i === 1 ) : ?>
<strong><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></strong>
<p><?php the_excerpt(); ?></p>
<?php else :
// Other posts ?>
<strong><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></strong>
<hr size="1" color="#919191">
<?php
endif;
endwhile;
?>