你真的不需要“排除”任何东西。只需利用内置的循环跟踪。WP_Query
会“记住”你在哪里停下来的。例如:
if (have_posts()) {
while (have_posts()) {
the_post();
echo \'firstpost##\';
the_content();
echo \'##endfirstpost\';
break;
}
}
// do some other stuff
if (have_posts()) {
while (have_posts()) {
the_post();
echo \'otherposts##\';
the_content();
echo \'##endotherposts\';
break;
}
}
或者将代码滚到同一个循环中:
if (have_posts()) {
while (have_posts()) {
the_post();
if (0 == $wp_query->current_post) {
echo \'firstpost##\';
else {
echo \'otherposts##\';
}
the_content();
if (0 == $wp_query->current_post) {
echo \'##endfirstpost\';
else {
echo \'##endotherposts\';
}
break;
}
}