This won’t matter to most WordPress.com users but I removed a bunch of unreachable code from almost every template file in Sandbox. The logic of this should be understood by all theme authors so that you don’t waste your time maintaining useless code!
This is the crux: at the top of the main loop,
is_404() are mutually exclusive. If we have posts it is not a 404. If it is a 404 we have no posts. If
is_404(), template-redirect.php sends us to 404.php (index.php if that’s missing). Thus
have_posts() will never be false at the top of single.php, archive.php, etc. unless a plugin is doing something very wrong.
Does your theme provide an
else handling in every loop of every template file? If it does you’re maintaining code that will never be executed by the server. Do yourself a favor and execute it–with an axe.
So why are so many themes testing
have_posts() at the top of the loop? The bundled themes have been recycled without enough critical thinking. Probably the documentation needs a comb-through. I’m generally too busy thinking up new stuff to worry about all that old stuff. Bad Andy. Will somebody step up?