[wp-hackers] Organizing my theme's functions.php file

Justin Tadlock justin at justintadlock.com
Fri Aug 16 16:46:23 UTC 2013

>> 2. Based on Justin's excellent article above, I'm under the impression
>> that I should move all of my `add_action()`'s, `remove_action()`'s,
>> `add_filter()`'s, `remove_filter()`'s (and similar) into the
>> `foo_setup` function (which is hooked into `after_setup_theme`)? In
>> other words, should my functions.php file look more like this:
>> <https://gist.github.com/mhulse/6245870#file-2-pseudo-functions-after-php>
> I'm not sure what the logic behind that would be. The child theme won't be able to remove any of the actions or filters like it normally would if they aren't added until 'after_setup_theme'; it would have to hook into a later action just to manipulate the actions of the parent theme. At least that's what I'm thinking, correct me if I'm wrong.

If you put an action/filter in functions.php, it can't be removed by a 
child theme because a child theme's functions.php is loaded before the 
parent theme's functions.php.  Hooking this code on 'after_setup_theme' 
gives child themes an opportunity to change this.  Of course, this is 
all explained in the referenced article.

More information about the wp-hackers mailing list