The actual query for a Theme’s page templates happens in wp_get_theme()->get_page_templates()
(source), which in turn calls get_files()
(source).
The magic happens here:
$files = (array) $this->get_files( 'php', 1 );
The args for get_files()
are:
function get_files( $type = null, $depth = 0, $search_parent = false ) {}
So, when WordPress searches the Theme for PHP files, it passes a $depth
argument of 1
, which means that it searches in subdirectories of the Theme root directory.