您需要使用offset WP\\U查询中的参数,例如。
<?php
$loop = new WP_Query( array( \'post_type\' => \'recentproject\', \'orderby\' => \'rand\', \'posts_per_page\' => \'1\') );
$counter=0;
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); $counter++; ?>
<div class="col-8 columns">
<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<?php echo get_the_post_thumbnail(); ?>
<?php endif; ?>
</div>
<div class="col-4 columns">
<h4 class="project_title"><?php the_title(); ?></h2>
<?php echo the_content(); ?>
</div>
<?php endwhile; ?>
<div class="clear"></div>
<div class="row">
<?php
$loop = new WP_Query( array( \'post_type\' => \'recentproject\', \'orderby\' => \'rand\', \'posts_per_page\' => \'3\', \'offset\' => \'1\' ) );
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="col-4 columns">
<h4 class="project_title"><?php the_title(); ?></h4>
<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<?php echo get_the_post_thumbnail(); ?>
<?php endif; ?>
<?php echo the_content(); ?>
</div>
<?php endwhile; ?>
</div>
基本上,它会忽略查询中的前xx篇文章,因此如果要忽略查询中的第一篇文章,可以使用offset=>1
我不认为它会与“兰德”订单一起工作,但兰德是必要的吗?Edit: Using count & 1 query
<?php
$loop = new WP_Query( array( \'post_type\' => \'recentproject\', \'orderby\' => \'rand\', \'posts_per_page\' => \'4\') );
$count = 1;
while ( $loop->have_posts() ) : $loop->the_post();
if($count == \'1\') { ?>
<div class="col-8 columns">
<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<?php echo get_the_post_thumbnail(); ?>
<?php endif; ?>
</div>
<div class="col-4 columns">
<h4 class="project_title"><?php the_title(); ?></h4>
<?php echo the_content(); ?>
</div>
<?php } else { ?>
<div class="col-4 columns">
<h4 class="project_title"><?php the_title(); ?></h4>
<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<?php echo get_the_post_thumbnail(); ?>
<?php endif; ?>
<?php echo the_content(); ?>
</div>
<?php
}
$count++;
endwhile;
wp_reset_postdata();
?>
未测试,但应该可以工作,基本上它会统计帖子,并根据计数更改HTML代码