[theme-reviewers] get_template_part vs locate_template
Chip Bennett
chip at chipbennett.net
Fri Apr 22 17:04:31 UTC 2011
get_template_part() is a specific wrapper for locate_template().
I would generally say that the former function is preferred, unless it
cannot be used. Also note that *both* of these functions are primarily
intended for including *template* files - i.e. markup files, rather than
code/function files.
I would also generally say that code/function files should be included in
functions.php, rather than being dumped into template files.
Chip
On Fri, Apr 22, 2011 at 12:01 PM, Towfiq I. <tislam100 at gmail.com> wrote:
>
>
> So if we want to load a file from a sub-directory(for example
> "mytheme/lib/my_codes.php") we can use this:
>
> <?php locate_template( array( '/lib/my_codes.php' ), 1); ?>
>
> IF it works and if it is advised, then I gotta say it will be a huge
> relief. I always wondered how to load files that are located in
> sub-directory of the theme folder. Didn't know it can be done with
> get_template_part() hook since it is not mentioned in
> http://codex.wordpress.org/Function_Reference/get_template_part
>
> Thanks.
>
> --
> Towfiq I.
>
>
> _______________________________________________
> 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/20110422/48b95821/attachment.htm>
More information about the theme-reviewers
mailing list