The WordPress template hierarchy determines which PHP template files will be used to construct a given webpage on your site, based on the type of post content requested: for example, whether the webpage displays a Page, a Post, or an archive of many Posts.
The template hierarchy follows a defined order set in WordPress itself. Learning this hierarchy will let you pinpoint which of your webpages will use which template.
Remember our analogy from WordPress is a Factory: A Technical Introduction: WordPress is a factory that processes raw material, posts, into finished products, webpages.
So here's where we are in the production process: a bundle of posts has been fetched out of the warehouse (the database), and they're all ready to be assembled and made to display beautifully by our assembly line, the WordPress theme.
However, the theme provides a lot of possible lines to send those posts down: our different PHP templates. Putting our posts through in...