The Wordpress hierarchy determines which template file to use when loading a web page. Wordpress uses database to run its websites. When a web page is called, the database is queried and Wordpress uses a query string to figure out which template to use. Wordpress then goes through the template hierarchy to find a matching file. If a match isn't found it keeps moving down through the hierarchy until it runs out of files to check. At that point it uses the theme main template file, index.php.
The order of the hierarchy on WordPress is:
- Front Page: home.php
- Single Post: single-{post-type}-{slug}.php
- Category: category-{slug}.php
- Tag: tag-{slug}.php
- Custom taxonomies: taxonomy-{taxonomy}-{term}.php
- Custom post types: archive-{post_type}.php
- Author: author-{name}.php
- Date: date.php
- Search Results: search.php
- 404 error: 404.php
WordPress uses strict practices for naming conventions. They use all lower case words and connect words with hyphens. This is done because it is more readable, better for SEO, and is a WordPress coding standard.
The WordPress template hierarchy is how WordPress decides which templates to use for displaying a web page. It starts by looking for a specific file, and if it doesn't find that file, it moves on to more general files. If it continues to not match the file its looking for, it will automatically load the index.php file. The order it checks depends on the content, like posts, pages, or categories. You can use either slugs or Id's in file names. Slugs are more human readable URL's and Id's are unique numbers. Slugs are better for SEO and easier to manage. Id's are guaranteed to be unique.