M
M
Mauster2016-01-31 22:36:17
css
Mauster, 2016-01-31 22:36:17

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

2 answer(s)
N
Nikita Souvel, 2016-01-31
@Souvel1

Before while
Inside while, after the_post();

$i ++;
global $wp_query;
if ( $wp_query->found_posts == $i ) 
  continue;

M
Mauster, 2016-02-03
@Mauster

Nothing happened. Here is the answer if anyone needs
Before while
Inside while, after the_post();

<?php $count++; ?>
<?php if ($count > 1) : ?>
 //Ваш пост
<?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question