Designing flexible WordPress themes.
The average WordPress theme has different files for pages, single posts, archives and the front page; however, most of them are almost exactly the same except for inside the_loop. This is a quick tutorial on how to do the most with the fewest files, and includes a few methods to have custom templates by separating content display from structural elements. WordPress looks first for special files and then defaults to the index.php file (as shown in this diagram).