4R - Template Hierarchy System

Template Heirarchy System

The Wordpress Template Hierarchy System is how Wordpress decides which templates to apply to the requested page. Templates can be unique to individual pages if the name of the template matches the slug of the requested page.

Order

Each type of page has its own template path. Wordpress will first look for a page template, then for a matching slug, followed by a matching ID number. If these all fail, there are a set of fallback files, depending on the type of page that's being requested. The final fallback regardless of type is index.php.

File Naming Conventions

Wordpress specifically looks for php files with a matching slug or ID. Template files should be lower case and separated by hyphens or underscores.

Summary

Pages can have a unique design with their own template files. The Template Heirarchy System decides which templates get applied to each page.