将您的代码分成 2 个循环。
特色帖子的第一个循环:
<?php query_posts('showposts=1'); ?>
<section class="latest-blog">
<?php $i = 0; while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- Post Title -->
<h1>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
<!-- /Post Title -->
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<?php endwhile; ?>
</section>
其余帖子的第二个循环:
<?php wp_reset_query(); ?>
<?php query_posts('showposts=5&offset=1'); ?>
<section class="archive">
<?php $i = 0; while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- Post Title -->
<h1>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
<!-- /Post Title -->
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<?php endwhile; ?>
</section>
您会注意到我们在查询中使用 offset=1 来偏移第二个循环的第一个帖子(因此它不会出现两次)。
您的最终代码将如下所示:
<?php if (have_posts()): ?>
<?php query_posts('showposts=1'); ?>
<section class="latest-blog">
<?php $i = 0; while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- Post Title -->
<h1>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
<!-- /Post Title -->
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<?php endwhile; ?>
</section>
<?php wp_reset_query(); ?>
<?php query_posts('showposts=5&offset=1'); ?>
<section class="archive">
<?php $i = 0; while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- Post Title -->
<h1>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
<!-- /Post Title -->
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<?php endwhile; ?>
</section>
<?php endif; ?>