Skip to main content
Notice removed Draw attention by Scott
Bounty Ended with Fayaz's answer chosen by Scott
Tweeted twitter.com/StackWordPress/status/1034093292772892673
Improved title, question description and tag.
Source Link

Move How to move page template files like page-{slug}.php to subdirectory to stay organizeda sub-directory?

I want to move mypage template files like page-{slug}.php files to a subdirectory andsub-directory within my theme, in a way that WordPress shouldwill 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 couldcan I achieve that? (Unfortunately

Note-1: thisThis did not help me -question and corresponding answers are more generic for page templates and this link mentions template-parts/page, which does alsois not work)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.

Move page-slug.php to subdirectory to stay organized?

I want to move my page-slug.php files to a subdirectory and WordPress should recognize them automatically. How could I achieve that? (Unfortunately this did not help me - and this link mentions template-parts/page, which does also not work)

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.

Notice added Draw attention by Scott
Bounty Started worth 50 reputation by Scott
Source Link
manifestor
  • 313
  • 6
  • 15

Move page-slug.php to subdirectory to stay organized?

I want to move my page-slug.php files to a subdirectory and WordPress should recognize them automatically. How could I achieve that? (Unfortunately this did not help me - and this link mentions template-parts/page, which does also not work)