runeveryday — 2011-04-23T02:16:46-04:00 — #1
i found this code
<?php if ( have_posts() ): while ( have_posts() ): the_post(); ?>
using in the default theme
? it's a redundant!because in the single.php,it's only one post, it's useless to use the while loop.am i right? why not delete it?
runeveryday — 2011-04-24T22:06:48-04:00 — #2
beebs93 — 2011-04-25T15:54:39-04:00 — #3
If you check wp-includes/query.php, WP is basically checking that a post exists before attempting to render. While only one post should be "loaded" while viewing an individual post, the way WP checks this is the same if there are 100 posts or just one.
If this wasn't checked for single.php (or loop-single.php) then a user who reloads a post that has just been removed (or visits a broken link) would most likely see an unfriendly PHP error -- probably about calling a method on a non-object (just a guess).