Check if next post exist.
-
I need to check, if in the loop next post exist.
Someone adviced me to use this:<?php $my_query = new WP_Query('category_name=portfolio&showposts=9999'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); $i++; ?> <?php the_title(); ?> <?php if ($my_query->have_posts()) : ?> <hr /> <?php endif; ?> <?php endwhile; ?>
But this solution makes the loop goes infinity (afret first pass on all posts, it goes over again).
So what is the method to check if the next post exist, and if so, then do something (display hr in example)?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Check if next post exist.’ is closed to new replies.