[wp-trac] [WordPress Trac] #15086: get_template_part() should let you specify a directory

WordPress Trac wp-trac at lists.automattic.com
Mon Oct 11 07:12:57 UTC 2010


#15086: get_template_part() should let you specify a directory
---------------------------+------------------------------------------------
 Reporter:  aaroncampbell  |       Owner:                 
     Type:  enhancement    |      Status:  new            
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Themes         |     Version:  3.0            
 Severity:  normal         |    Keywords:  dev-feedback   
---------------------------+------------------------------------------------

Comment(by Viper007Bond):

 Replying to [comment:6 westi]:
 > It looks like @Viper007Bond added the directory example to the codex :-(
 >
 http://codex.wordpress.org/index.php?title=Function_Reference/get_template_part&diff=92384&oldid=90074

 I added it as a WP.com VIP did it and I thought it was a clever
 organizational method. I didn't realize it wasn't intentional to allow
 such a thing. :)

 Personally I really like the idea of it though. Say for example you have a
 bunch of ad template parts. Rather than having to clutter up the main
 directory, you can just make an "ads" folder and stick all your ad
 templates in there.

 We shouldn't break backwards compatibility by not allowing slashes in my
 opinion. Perhaps we can deprecate it though in favor of an additional
 argument so that `get_template_part( 'banner', false, 'ads' )` will look
 for `/ads/banner.php` and then `/ads-banner.php` or something.

 Or maybe we just leave it as is with some better security (probably the
 best).

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


More information about the wp-trac mailing list