[wp-hackers] Child theme functions.php & processing order
Ghodmode
ghodmode at ghodmode.com
Fri Dec 11 05:34:44 UTC 2009
On 11/12/09 15:36, Demetris wrote:
> On Fri, Dec 11, 2009 at 3:32 AM, Doug Stewart<zamoose at gmail.com> wrote:
>
>> Howdy all. I need a gentle shove in the right direction on this one.
>>
>> When processing a child theme, which ends up getting executed by WordPress
>> first, the child or the parent functions.php? And, parallel to this, if I
>> have action or filter hooks registered in the parent, what's the best way to
>> ensure that my child theme can override/alter the parent's functions?
>>
>>
> Answering to the first question:
>
> The child’s functions.php is executed first.
>
> I would expect it to be the other way around. (But I have no idea if
> it matters. For example, when both parent and child register one
> function or filter each to the same hook, the order can be adapted
> with the priority argument. But probably there are scenarios that I’m
> missing.)
>
> Cheers!
>
> Demetris
> http://op111.net/
>
I found this related article :
http://venutip.com/content/right-way-override-theme-functions
And here's the related codex page :
http://codex.wordpress.org/Theme_Development#Theme_Functions_File
They're loaded from /wp-settings.php around lines 669-672...
> // Load functions for active theme.
> if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH .
> '/functions.php') )
> include(STYLESHEETPATH . '/functions.php');
> if ( file_exists(TEMPLATEPATH . '/functions.php') )
> include(TEMPLATEPATH . '/functions.php');
Where TEMPLATEPATH is the parent template's path and STYLESHEETPATH is
the child template's path (I think :-) )
So, if you have a function in your child template's functions.php that
has the same name as one from the parent's functions.php, I guess the
one from the parent is the one that will be used unless you use the
remove_action() function as Ian suggested. There's more detail in that
related article.
I thought it didn't even use the functions.php from the parent if there
was a functions.php in the child template directory, but I see now that
I was wrong.
--
*Ghodmode*
www.ghodmode.com <http://www.ghodmode.com>
More information about the wp-hackers
mailing list