我有三个循环,我想阻止他们在每个循环中显示相同的帖子。
任何帮助都将不胜感激
<?php
$i;
$args = array( \'numberposts\' => 8);
$posts= get_posts( $args );
if ($posts) {
foreach ( $posts as $i => $post )
{
setup_postdata($post);
}
}
?>
<div class="item" id="<?php echo $i; ?>" >
<?php
$a = 0;
foreach( $posts as $i => $post ) :
if ($a == 4) { break; }
?>
<div class="col-md-6 nopadding view view-ninth" style="">
<?php the_post_thumbnail(\'large\'); ?>
<div class="content">
<h2><?php the_title(); ;?></h2>
<p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,15) . \'...\'; ?></p>
<a href="<?php the_permalink() ?>" class="info">Read More >></a>
</div>
</div>
<?php $a++; endforeach; ?>
</div><!-- end item -->
<div class="item" id="<?php echo $i; ?>" >
<?php
$a = 0;
foreach( $posts as $i => $post ) :
if ($a == 4) { break; }
?>
<div class="col-md-6 nopadding view view-ninth" style="">
<?php the_post_thumbnail(\'large\'); ?>
<div class="content">
<h2><?php the_title(); ;?></h2>
<p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,15) . \'...\'; ?></p>
<a href="<?php the_permalink() ?>" class="info">Read More >></a>
</div>
</div>
<?php $a++; endforeach; ?>
</div>
<div class="item" id="<?php echo $i+1; ?>" >
<?php
$a = 0;
foreach( $posts as $i => $post ) :
if ($a == 4) { break; }
?>
<div class="col-md-6 nopadding view view-ninth" style="">
<?php the_post_thumbnail(\'large\'); ?>
<div class="content">
<h2><?php the_title(); ;?></h2>
<p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,15) . \'...\'; ?></p>
<a href="<?php the_permalink() ?>" class="info">Read More >></a>
</div>
</div>
<?php $a++; endforeach; ?>
</div>