0

I've set up the following loop on a page, but it is missing out the first post. Does anyone know why this might be?

<div class="gallery">
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="gallery-item">
      <a href="<?php esc_url( the_permalink() ); ?>">
        <?php the_post_thumbnail('thumbnail'); ?>
        <div class="view-item">
          <span>
            <h2><?php the_title(); ?></h2>
            <p>View project</p>
          </span>
        </div>
      </a>
    </div>  
  <?php endwhile; ?>
  </div>
  <?php bones_page_navi(); ?>
  <?php endif; ?>
</div>
0

It looks OK to me. There is nothing wrong with this part of your code.

Maybe some earlier part is doing something strange with your $wp_query variable.

You can try to add rewind_posts() before your loop - it should help. Just place rewind_posts(); just before if (have_posts())....

  • Added rewind_posts() where you suggested and this worked. Wonder what was causing this! – jasonbradberry Aug 6 '13 at 12:43
  • Search for the_post function calls placed before this loop. – Krzysiek Dróżdż Aug 6 '13 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.