wp-includes/template-loader.php
is the file which is the template hierarchy. However, by the time that file executes, all the template decisions are already made since all that file does is check for boolean flags (defined in wp-includes/query.php
function init_query_flags
).
So all the heavy-lifting and interesting code happens before that at wp-settings.php
line 225:
$wp_the_query = new WP_Query();
and it is definitely inside of the WP_Query class (starting with the constructor in wp-includes/query.php
line 2998) where all the interesting logic happens.
Related Posts:
- Template Hierarchy: confused with index.php, front-page.php, home.php
- How to use a specific category archive index as the site front page?
- Overriding default template if page slug and post type are same
- Change Page Template Based on Category
- Load custom template for specific GET parameter
- WordPress Page Hierarchy
- How to force sub-product-category to use the parent category template
- How to determine the template loaded when you are not an Admin?
- Template hierarchy override
- How to define the template priority between built-in categories and custom taxonomies?
- What is the difference between the “Main Index Template”(index.php) and HomePage(front-page.php)
- About template hierarchy
- Front-Page.php and Index.php
- Displaying a custom post type and an archive page
- Which page is referring to *all posts by author*?
- How to determine top level template file in functions.php? [duplicate]
- Get the current hierarchy php page
- How to create custom 401, 403 and 500 error pages?
- What is singular.php?
- Custom Post Type Plugin: Where Do I Put The Template?
- CPT Template Not Showing – Getting 404
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- Which template name to use for taxonomies but not their terms?
- LOST in WP Template Hireachy
- Templates & CSS – Proper Programming Practice?
- How to Handle CSS for Multiple Header header.php Files?
- page_template toggle between 2 templates + 2 permalinks for same post
- Static Front Page problem
- Archive or taxonomy pages not working for custom post type
- Trying to manage templates on a blog with lots of custom taxonomies
- Taxonomy landing pages
- is_archive() content being shown instead of is_category()
- Categories Template Assistance
- How to apply a custom template for posts by default?
- Which php file lists all the post of a category
- Displaying all Video Post Formats to Page
- How can a Theme Contain no Header File or Footer File?
- Rewrite Custom Post Type URL slug
- Custom post type and taxonomy permalinks – Structure
- WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
- Understanding the WordPress template hierarchy
- Custom Taxonomy term archive template
- When a link doesn’t exist, how to tell WordPress what to do? (404 Error Page)
- Simple way to get two language WP site
- Create static front-page with 3-5 recent posts
- WordPress Ignoring My Custom Post Type Templates?
- Include custom post type single template, but respect theme override of template if it exists
- Override template file i subfolders
- is_home() returns TRUE on page template
- WordPress Pagination changes my template
- How to show single category archive
- How to overwrite core/libraries/vendor template with child theme
- How to use multiple archive templates for a taxonomy?
- WordPress Filtering Custom Post Type by Metadata and Search Heirachy
- How to load parent theme template parts in child theme
- Selected template is not respected for home page in WordPress
- Understanding the Template hierarchy
- How does WordPress choose archive type template?
- How can I conditionally show different home page templates based on whether or not the user is logged in?
- Will renaming a `content.php` file cause any problems?
- how to force tag page layout to use same as search layout?
- Avoid taxonomy-%term%.php if more than one taxonomy
- Custom post type not respecting template hierarchy
- Differentiation between index.php and page.php
- Single-page.php template file name not shown
- Templates for hierarchical custom post type
- How to display custom post type?
- Custom Post Type homepage template
- Custom term templates
- Getting custom taxonomy posts on archive page
- how to access the $query variable inside taxonomy-xxx.php template file?
- loading custom registration template
- Custom post types templates
- anchor tag in header not working on other pages except the home page
- How to Override Page Template if URL matches query?
- Overriding the template files using a plugin for all themes
- Custom Archive Template for Multiple Categories
- Static page won’t identify template
- custom post template not getting picked for posts with Unicode title
- bbPress: modifying template for forum index
- Custom TaxonomyTemplate
- Single taxonomy for different custom post types
- Letting wordpress decide what template and page to use based on condition
- Which template(s) to override to use a different sidebar for blog, single posts, categories, blog archive?
- Different template for subcategories
- How can I modify wp_get_archives() to not use archive.php template?
- Custom Post Type Archive – archive.php is present, but it is not being used
- Ajax specific template not loading in replacement of index.php
- Creating a Taxonomy Page [duplicate]
- Show a custom template, no matter the page being viewed, if the user is not logged in
- Most efficient way to have 1 template for parent, 1 template for child categories?
- Passing query variables to a custom page template
- WP Template Hierarchy – Need help choosing the correct templates
- List a custom taxonomy’s terms, with links, on the taxonomy page
- 404 on child page template
- Utilizing the template hierarchy while storing page templates in a subdirectory
- Archive for custom fields?
- Custom taxonomy meta fields
- Template hierarchy html with taxonomy in 6.2
- Unload templates; disable parent Template Parts using only “theme.json”