Why do themes have `while( have_posts() )` in templates like single.php?

The idea is to ensure that all the content is displayed properly. Some functions are not available outside of The Loop, as it’s called, so depending on what you are doing, it may be advantageous to start the loop, even if you’re relatively certain it will only be used for one post object.

Leave a Comment