WordPress.org

Support

Support » Themes and Templates » What do endwhile; and endif; do in the loop?

What do endwhile; and endif; do in the loop?

  • Hi, I have just started to learn about wordpress development. What do endwhile; and endif; do in the loop?

    <?php (have_posts () ) : while (have_posts () ) : the_post (); ?>
    
    And ends with this:
    
    <?php endwhile; else: ?>
    <p> some error message or similar . </p>
    <?php endif; ?>

    In the examples I’ve looked through, endwhile; and endif; are always near the end of the loop. But what does endwhile specifically do? And what does endif specifically do?

    Many thanks for reading this 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘What do endwhile; and endif; do in the loop?’ is closed to new replies.