This is going to sound quite stupid for most experts but for a beginner it's not clear what .php code gets called when visiting a home_url/year/month URL.

For example, domain.com/2018/05 shows all posts from that specific months.

Apparently, the same .php gets called for domain.com/2018 too (except with more results).

I've looked left and right and read about archives.php (which I have) but it doesn't correspond with what actually gets rendered.

In some places I've read about date.php too, but I don't have such file.

Right now I'm specifically interested for archives, but with this question I'm looking for a general way to know exactly what php files are involved for a specific URL?

I am aware of this post but this talks about wordpress initialization. I'm interested in the first php file used for a given URL.

  • There's a lot of code that's run when you visit any page in WordPress. Do you just mean which template is used? Commented Jul 13, 2018 at 12:54
  • I'm not familiar with all the terms of wordpress. Perhaps yes, which template. I'd say what file
    – Adelin
    Commented Jul 13, 2018 at 12:57
  • All URLs in WordPress go through /index.php, which loads the WordPress application (which comprises dozens of files) which then performs operations to determine what to display and does that by assembling multiple files from the theme according to the template hierarchy. If you're trying to achieve something in particular it might help to know what so you can get a more specific answer. Commented Jul 13, 2018 at 13:04
  • 1
    WordPress's doesn't really use 'routes'. See this question and answer for a rough overview of how URLs are parsed in WordPress. Commented Jul 13, 2018 at 13:19
  • 1
    Install the Query Monitor plugin - that will tell you which template file is being used.
    – Peter HvD
    Commented Jul 13, 2018 at 13:23

1 Answer 1


Here's an answer I posted elsewhere here:

WordPress is not HTML. It's PHP-based templates that build the HTML pages.

You need more than just a quick answer. You need to learn about the entire process WordPress uses to build pages.

Perhaps one place is to start here to figure out how WP works: https://codex.wordpress.org/New_To_WordPress_-_Where_to_Start . And if you are not comfortable with PHP, then you need to get some basics about how it works so you will understand the code behind the WP templates. Perhaps start here to learn about PHP: https://www.w3schools.com/pHP/default.asp .

This is not going to be a quick process. It will take some time and effort on your part. But you might have fun doing it.

  • Weird how WP is advertised at being so quick to use yet when it comes to doing just a little more you need to know everything
    – Adelin
    Commented Jul 13, 2018 at 17:37
  • If you want to change how your site works with content, then you need to grok how WP works, and how it uses templates to get data and format it for viewing; see my link. Templates are the 'PHP file used for a page'. The templates use built-in WP functions -WP is the 'engine', and template files are the 'content formatters' that use data provided by the engine. The 'engine' does all the work involved in getting/storing data. Themes: collection of templates and CSS that format the output to HTML for the visitor. Plugins:extensions to the engine that add capability. Read the links to understand. Commented Jul 13, 2018 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.