[wp-trac] [WordPress Trac] #21676: Pass a variable to get_template_part()

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 14 19:01:57 UTC 2012


#21676: Pass a variable to get_template_part()
-------------------------------------+-----------------------------
 Reporter:  sc0ttkclark              |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Future Release
Component:  Template                 |     Version:  3.4.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+-----------------------------

Comment (by scribu):

 I think nacin's implicit objection is this:

 Adding a $data parameter to get_template_part() is wrong because it mixes
 two ways of "templating":

 1) The "WordPress" way, where you call the_title(), the_content() etc. +
 globals like $wp_query.

 2) The "bare-bones" way, where you pass an array of data, which gets
 converted into some variables:

 {{{
 function wp_load_template( $path, $data ) {
   extract( $data );
   include $path;
 }
 }}}

 @wonderboymusic: Do you chat with your mother using those fingers? :P

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


More information about the wp-trac mailing list