Adding if statement causing endless loop?
I’m trying to modify a theme so that it only adds a horizontal rule between posts. I’m trying to do it like this:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php require(‘post.php’); ?>
<?php if (have_posts()) echo ‘<div class=”line”></div>’; ?> // problem
<?php endwhile; ?>
For whatever reason, if the inside if statement is commented out, I have no problems. When it’s uncommented, the loop runs forever, and my blog starts repeating itself. Does the have_posts() function somehow increment back around to the first post? This is really confusing me. What do I need to change?
- The topic ‘Adding if statement causing endless loop?’ is closed to new replies.