[theme-reviewers] get_template_part()

Safirul Alredha zeo at zeo.my
Wed Jul 14 04:07:40 UTC 2010


get_template_part() is for WP 3.0 only.

locate_template() exist since WP 2.7.

Can't figure out any other better replacement for include() (if it
fits.) Been using that for a while.

Cheers!

--
zeo
http://twitter.com/o

On Sun, Jul 11, 2010 at 12:46 AM, Chip Bennett <chip at chipbennett.net> wrote:
> get_template_part() itself works just fine for either parent or child themes.
> I've switched all my calls to theme template files to use the function,
> instead of include().
>
> But I don't think it would work in the use-case in which the to-be-included
> file is in a subdirectory. I think that would still require an include() call.
>
> (Perhaps something to bring up in Trac, as a possible addition to
> get_template_part() ?)
>
> --
> Chip Bennett
> chip at chipbennett.net
> www.chipbennett.net
>
> On Saturday 10 July 2010 9:42:54 am Edward Caissie wrote:
>> Have you tested to see if your theory works using the get_template_part()
>> function?
>>
>> From what I am gathering from trunk and the description there, it appears
>> the function is designed to work for child-themes and is referring to the
>> use the title block element: "Template: <parent theme>".
>>
>> If this function does work internally to a stand-alone theme then I see it
>> as a nice little bit of code and much cleaner than the "include" version.
>>
>>
>> Cais
>>
>> On Sat, Jul 10, 2010 at 9:41 AM, Bavota San <c at bavotasan.com> wrote:
>> > I had asked about this and he suggested I ask the whole list so here it
>> > goes...
>> >
>> > If I have a file in a sub-folder, can I use get_template_part() to
>> > include it or will I still have to use
>> > include(TEMPLATEPATH.'/folder/file.php') and will that be allowed?
>> >
>> > Thanks.
>> >
>> > c.bavota
>> > Web Programmer
>> > c at bavotasan.com
>> > http://bavotasan.com
>> > http://themes.bavotasan.com
>> >
>> >
>> > Become an Affiliate and earn 40% commission on sale referrals
>> > http://themes.bavotasan.com/affiliates
>> >
>> >
>> >
>> > On 2010-07-10, at 7:59 AM, Chip Bennett wrote:
>> >
>> > Hmm... it appears that the first argument in the get_template_part()
>> > function
>> > call is a slug. So, I'm assuming that a file path wouldn't work directly.
>> >
>> > As for whether or not it will still be allowed: I'd ask the list as a
>> > whole. I
>> > assume it would still be allowed for such use case.
>> >
>> >
>> > --
>> > Chip Bennett
>> > chip at chipbennett.net
>> > www.chipbennett.net
>> >
>> > On Friday 09 July 2010 3:57:58 pm you wrote:
>> >
>> > Hey Chip,
>> >
>> >
>> > Out of curiosity, if I have a file in a sub-folder, can I use
>> >
>> > get_template_part() to include it or will I still have to use
>> >
>> > include(TEMPLATEPATH.'/folder/file.php') and will that be allowed?
>> >
>> >
>> > Thanks.
>> >
>> >
>> > c.bavota
>> >
>> > Web Programmer
>> >
>> > c at bavotasan.com
>> >
>> > http://bavotasan.com
>> >
>> > http://themes.bavotasan.com
>> >
>> >
>> >
>> >
>> > Become an Affiliate and earn 40% commission on sale referrals
>> >
>> > http://themes.bavotasan.com/affiliates
>> >
>> >
>> > On 2010-07-08, at 8:05 AM, Chip Bennett wrote:
>> >
>> > Good morning, Theme Reviewers!
>> >
>> >
>> > Another question: when we start requiring 3.0 compatibility, should we
>> >
>> > require include() to be replaced by get_template_part(), for including
>> >
>> > generic theme template files?
>> >
>> >
>> > The benefits would be obvious. Would there be any downside to such a
>> >
>> > requirement?
>> >
>> >
>> >
>> > _______________________________________________
>> > theme-reviewers mailing list
>> > 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
>
>


More information about the theme-reviewers mailing list