[wp-trac] [WordPress Trac] #10959: Inconsistent handling of template files in subdirectories under theme directories

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 16 05:57:44 UTC 2009


#10959: Inconsistent handling of template files in subdirectories under theme
directories
------------------------------------+---------------------------------------
 Reporter:  eyelidlessness          |        Owner:  westi   
     Type:  defect (bug)            |       Status:  reopened
 Priority:  normal                  |    Milestone:  2.9     
Component:  Template                |      Version:  2.8.4   
 Severity:  normal                  |   Resolution:          
 Keywords:  has-patch subdirectory  |  
------------------------------------+---------------------------------------

Comment(by greenshady):

 In WordPress 2.8.6, templates are recognized in the top level of the
 directory for both parent and child themes.  With the last committed code,
 `get_template_directory()` is removed from the template file name.  By
 doing this instead of using `basename( $template )`, templates in child
 themes are recognized but still have the full path in front of the file
 name when added as a meta value to `_wp_page_template`.  It should only be
 the file name itself.

 If we go this route, we need to also remove `get_stylesheet_directory()`
 from the template name so that child theme templates are loaded correctly
 on the front end.

 The original problem in this thread is that templates are recognized in
 sub-directories in parent themes (but not child themes).  Since the
 `get_page_templates()` function removes the path, only the file name is
 used as the `_wp_page_template` meta value.  This causes a problem when
 loading the template on the front end because WordPress will be looking
 for it in the top level of the theme directory instead of in the sub-
 directory.

 Possible solutions:

 1) Don't recognize templates in sub-directories at all.
 2) Recognize templates within sub-directories of both parent and child
 themes.
 3) Fix the last committed code to at least allow templates in a child
 theme to work as before.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10959#comment:12>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list