Skip to main content
2 of 2
Improved title, question description and tag.

How to move page template files like page-{slug}.php to a sub-directory?

I want to move page template files like page-{slug}.php to a sub-directory within my theme, in a way that WordPress will recognize them automatically. If the page templates of the said form doesn't exist within the sub-directory, then WordPress should fall back to the default template loading rules. How can I achieve that?

Note-1: This question and corresponding answers are more generic for page templates and this link mentions template-parts/page, which is not the same thing.

Note-2: I have multiple page-{slug}.php like page template files, so I want to move them to sub-directory for a more tidy file organization.

manifestor
  • 313
  • 6
  • 15