[wp-hackers] Organizing my theme's functions.php file
mickyhulse.lists at gmail.com
Fri Aug 16 17:36:18 UTC 2013
Hi Justin! Thanks so much for the reply, I really appreciate it!
Loved your article. I know it's a couple years old now, but it still
seems like it's packed with some awesome tips on `functions.php`
Out of curiosity, because the article is a little older, and WP has
evolved a little since then, have you discovered anything new that
isn't in your article?
On Fri, Aug 16, 2013 at 9:46 AM, Justin Tadlock
<justin at justintadlock.com> wrote:
> On Fri, Aug 16, 2013 at 6:19 AM, J.D. Grimes <jdg at codesymphony.co> wrote:
>> 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.
... and I hate to sound like a dunce, but there was so much info
packed into that article, that I found myself having to read it a few
extra times and then ask for help with the professionals on this list.
I'm still trying to wrap my head around all the tips (on top of all
the other great links/resources folks have pointed me towards).
With that said, if it's not too much trouble, could you take a quick
look at my pseudocode `functions.php` examples:
Just to be clear, in the above Gist, the first file is "BEFORE" and
the second is "AFTER".
1. In the second file (the "AFTER"), is that basically what your
article is recommending? Essentially, your saying to move all
action/filters into `after_setup_theme`?
2. I did not see an example in your article where a you show a
action/filter/other outside of `after_setup_theme`; are there
situation where you wouldn't wan't to put an action/filter inside
`after_setup_theme` (other than if you didn't want something to be
3. Have you built a theme, one that I could look at, that uses the
techniques you explain in your blog post?
4. Is there a reason why a theme like `twentyfourteen` doesn't follow
these guidelines? Is it because that theme wasn't meant to have
Again, sorry for being dense here. I just really want to fully
understand the tips you provide in your article.
Thanks for your time.
Thanks to everyone for listening to (and helping to answer) my silly questions.
Have an awesome day!
More information about the wp-hackers