[theme-reviewers] get_template_part()

Justin Tadlock justin at justintadlock.com
Fri Jun 8 15:45:28 UTC 2012


Technically, get_template_part() was not meant to be used to get files 
in sub-directories.  This was an oversight when the function was 
originally written.  Fixing it in core would bring up backward 
compatibility concerns because theme authors decided to start using it 
incorrectly.

A more appropriate function for getting templates files in 
sub-directories would be locate_template().

On 6/8/2012 7:57 AM, Chip Bennett wrote:
> Note:
>
> get_template_part() should be used for *template* - i.e. *front-end* - 
> files. It is perfectly acceptable (and correct) to use 
> include()/require() for *functional* files to be included within 
> functions.php. There may still be cases where get_template_part() is 
> insufficient, in which case locate_template() should be used directly.
>
> Thanks,
>
> Chip
>
> On Fri, Jun 8, 2012 at 6:52 AM, Central Victorian Irish Association 
> <info at cvia.com.au <mailto:info at cvia.com.au>> wrote:
>
>     Hello My Darlings. Smile with tongue out
>     I have a guy questioning the get_template_part() call on internal
>     files. He claims basically that it is not required because it
>     doesn't support directories. So, he wants to be an exception. I am
>     saying No-Can-Be-Doneskies but wanna get some experienced feedback
>     before I tell him to behave.
>     http://themes.trac.wordpress.org/ticket/7896
>     Thanks,
>     Dan
>
>     _______________________________________________
>     theme-reviewers mailing list
>     theme-reviewers at lists.wordpress.org
>     <mailto:theme-reviewers at lists.wordpress.org>
>     http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20120608/b9bb8c70/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1146 bytes
Desc: not available
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20120608/b9bb8c70/attachment.png>


More information about the theme-reviewers mailing list