I have a custom page template that I am trying to use on my WP site (version 4.9). The folder structure where I am placing my page templates are as follows.

theme-root (/wp-content/themes/mytheme/)
            |-index.php etc...

When all of the template files are placed up one level in theme-root/landing I can see the template in the page attributes box on the admin screen when editing the page. When it is placed inside the template-name folder it doesn't show up. I have a plugin to clear the file cache so the problem isn't from the caching of files. It is structured this way because the site uses multiple page templates.

1 Answer 1


In WP 3.4 they allowed adding template files one level deep.

Since then code has changed, however in wp-includes/class-wp-theme.php, in offsetGet() (from __get()) you'll see:

case 'Template Files' :
    $files = $this->get_files( 'php', 1 );

Although I can't fully unravel the maze of code for loading a theme, the above suggests the second argument, $depth, is still set to only 1 deep for Template Files. Which would coincide with the troubles your experiencing.

You may want to re-think your themes folder structure, and/or your logic for selecting a template.

If you're conditionally checking which template was chosen based on a user selection in the first place, on your conditions using the load_template() andor template_redirect() might help out more than leaving it to Wordpress defaults.


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.