How WordPress Decides Which File to Use for Rendering the View
If you have a question, “how does WordPress figure out which template file to Use for Rendering the View?”here is the answer. WordPress theme has hierarchy of template files and the index.php is the most important and required file.
If your theme doesn’t find any requested file, it moves down its hierarchy of template files to find the next most appropriate file to use.

Displaying a unique template file, you can create a file with unique name. For example, If you want to render the view for a Category #786 of your blog, create a file with this name category-785.php, and WordPress will automatically use it. Let’s take a look at the hierarchy flowchart from Digging into WordPress. In this book you will find more useful tips and tricks about developing a WordPress Theme.
Which Template File will WordPress Use
The Template Hierarchy
| PAGE TYPE | tries first | > | tries next | tries last | ||
| 404 | 404.php | > | index.php | |||
| SEARCH | search.php | > | index.php | |||
| TAXONOMY | taxonomy-{tax}-{term}.php | > | taxonomy-{tax}.php | taxonomy.php> | archive.php> | index.php |
| HOME | home.php | > | index.php | |||
| ATTACHMENT | {mime-type}.php | > | attachment.php | single.php > | index.php | |
| SINGLE | signle-{post-type}.php | > | single.php | index.php | ||
| PAGE | {custome-template}.php | > | page-{slug}.php | page-{id}.php> | page.php > | index.php |
| Category | category-{slug}.php | > | category-{id}.php | category.php> | archive.php> | index.php |
| TAG | tag-{slug}.php | > | tag-{id}.php | tag.php | archive.php> | index.php |
| AUTHOR | author-{author-nicename}.php | > | author-{author-id}.php | author.php > | archive.php> | index.php |
| DATE | date.php | > | archive.php | index.php | ||
| ARCHIVE | archive.php | > | index.php |































