如何在 WordPress 中显示一个类别中的第二个和第三个最近的帖子 [英] How do I display the second and third most recent posts from a category in WordPress
问题描述
我正在我的主页上显示最近三篇新闻文章的预览.最近的帖子将以与第二个和第三个最近的帖子不同的格式显示.我目前使用以下代码显示所有三个相同
<?php query_posts('cat=2 && showposts=3');if (have_posts()) : while (have_posts()) : the_post();?><div class="col-xs-12 col-sm-4"><div class="column"><div class="news-article"><p class="news-date"><?php the_time(get_option('date_format'));?></p><a href="<?php the_permalink(); ?>"><?php if ( has_post_thumbnail() ) { the_post_thumbnail('full', array( 'class' => 'img-responsive img-rounded news-img'));?><p class="news-headline"><?php the_title();?></p></a><p><?php the_excerpt();?></p><a href="<?php the_permalink(); ?>"><p class="pull-right">阅读更多...</p></a><span class="clearfix"></span>
<?php终了;万一;?>
如何添加另一个循环,将第二个和第三个最近的帖子与最近的帖子分开?我不想使用 postID,因为帖子会改变.
未经测试,但您可以尝试:
<div class="col-xs-12 col-sm-4"><div class="column"><div class="news-article"><p class="news-date"><?php the_time(get_option('date_format'));?></p><a href="<?php the_permalink(); ?>"><?php if ( has_post_thumbnail() ) { the_post_thumbnail('full', array( 'class' => 'img-responsive img-rounded news-img'));?><p class="news-headline"><?php the_title();?></p></a><p><?php the_excerpt();?></p><a href="<?php the_permalink(); ?>"><p class="pull-right">阅读更多...</p></a><span class="clearfix"></span>