[wp-hackers] Widget Weirdness - Doesn't like the file name widgets.php
Otto
otto at ottodestruct.com
Tue Jun 28 14:19:54 UTC 2011
The get_template_part function was never really intended to function
in that manner. It works, but is slightly sub-optimal for that use
case, and it is conceivable that this sort of use will stop working at
some point in the future.
Instead, consider using this:
locate_template('includes/widgets.php', true, true);
First true means to load the file, second true means to require_once
it (instead of simply requiring it). This also checks child themes as
well.
-Otto
On Tue, Jun 28, 2011 at 4:47 AM, John Blackbourn
<johnbillion+wp at gmail.com> wrote:
> On 28 June 2011 10:06, Alex Andrews <awgandrews at gmail.com> wrote:
>> Thanks for all this folks, learnt my lesson and may also submit a
>> patch to the Roots theme on this account.
>
> Another neat way to load files from within a theme is to use
> WordPress' get_template_part( 'includes/widgets') instead of a regular
> include() or require(). This allows a child theme to override these
> files in the same way core template files are overridden if they're
> present. Might be worth suggesting to the theme author.
>
> John
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list