How is WP_Query parsed to determine which template to request?

I noticed that when I changed the WP_Query to ask for a certain category, the page served was category.php. So I’m guessing there’s a block of code somewhere that decides which template to serve based on keys in the query. Where is it?

Related posts

Leave a Reply

1 comment

  1. The template loader determines which template to load for a given view, there’s a filter available to change this though, template_include as seen on the source page linked.

    Moved from comment to answer.