Concept Flow - Template hierarchy
Request URL
Check for specific template
front-page.php
index.php
Render Output
WordPress checks templates from most specific to general, using the first matching template file to render the page.
<?php if (is_front_page()) { get_template_part('front-page'); } elseif (is_single()) { get_template_part('single', get_post_type()); } else { get_template_part('index'); } ?>
| Step | Condition Checked | Result | Template Chosen | Action |
|---|---|---|---|---|
| 1 | Is front page? | Yes | front-page.php | Load front-page.php template |
| 2 | Is single post? | No | - | Skip single post templates |
| 3 | Is category archive? | No | - | Skip category templates |
| 4 | Is page? | No | - | Skip page templates |
| 5 | Fallback | - | index.php | Load index.php as fallback |
| 6 | Render | - | - | Output page using front-page.php |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| Template chosen | none | front-page.php | front-page.php | front-page.php | front-page.php | front-page.php |
WordPress Template Hierarchy:
- WordPress checks templates from most specific to general.
- It uses front-page.php for the homepage.
- For single posts, it tries single-{post-type}.php.
- If no specific template matches, it falls back to index.php.
- The first matching template stops the search and renders the page.