> For the complete documentation index, see [llms.txt](https://www.wptherightway.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.wptherightway.org/routing/the_main_loop_and_template_loading.md).

# The Main Loop & Template Loading

* The main query is a `WP_Query` object
* The main loop is using that main query
* The main query is done before the template is even loaded
* The template is loaded based on what the main query is
* The main query is determined by parameters called query variables
* Which template is loaded when is shown on the template hierarchy diagram
* All templates are just custom ways of showing the main post loop
