[wp-trac] [WordPress Trac] #13691: Make get_template_part() accept multiple template names

WordPress Trac wp-trac at lists.automattic.com
Mon Jul 12 03:08:49 UTC 2010


#13691: Make get_template_part() accept multiple template names
-------------------------+--------------------------------------------------
 Reporter:  wjm          |       Owner:                
     Type:  enhancement  |      Status:  new           
 Priority:  normal       |   Milestone:  Future Release
Component:  Template     |     Version:                
 Severity:  normal       |    Keywords:  has-patch     
-------------------------+--------------------------------------------------

Comment(by wjm):

 This is the first time i need to write something like this.
 If this is not the case, let me know and i will do my best to write it
 again.

 Allowing get_template_part() to take a second argument, allows theme
 designers to use "contextual" template parts.
 Letting them extend themes based on different situations.
 Working with a theme framework such as hybrid, which uses a function to
 get its context ( hybrid_get_context() will retrieve a list of contexts
 example

 {{{
 array (
     [0] => archive
     [1] => taxonomy
     [2] => category
     [3] => category-bananas
 )
 }}}


 so by calling ( get_template_part( array_reverse( hybrid_get_context() ) )
 )
 this way it is possible to call 'loop-category-bananas.php' just by
 creating the template file, but if that file is not present, then 'loop-
 category.php' is called, and so on.

 Letting theme designers focus on creating the files rather worrying about
 modifying the code.

 this change can also be applied to get_footer(), get_header(),
 get_sidebar()
 letting theme designer create featured footers, headers, sidebars for
 certain situations.

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


More information about the wp-trac mailing list