Answer the question
In order to leave comments, you need to log in
How to display posts in Wordpress except the last one?
Hello! I need to display posts in Wordpress, except for the last post, tell me how to do it.
Thank you in advance!
<?php if (have_posts()) { ?>
<?php while (have_posts()){ the_post(); ?>
<article class="article col-lg-33 col-md-33 col-sm-50 col-xs-100">
<div class="article-item">
<a href="<?php the_permalink() ?>"><?php IF ( has_post_thumbnail() ) { the_post_thumbnail('thumbnail'); } ?></a>
<div class="meta">
<span class="cat"><?php the_category(', ') ?></span>
<span class="comment"><i class="fa fa-comments-o"></i><a href=""><?php comments_number('0', '1', '%'); ?></a></span>
</div>
<header>
<h1><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h1>
</header>
<div class="description-text">
<?php the_excerpt(); ?>
</div>
</div>
</article>
<?php } ?>
<?php } else {?>
Answer the question
In order to leave comments, you need to log in
Before while
Inside while, after the_post();
$i ++;
global $wp_query;
if ( $wp_query->found_posts == $i )
continue;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question