Closed bryanwillis closed 9 years ago
WordPress executes both the child theme functions.php and the parent theme functions.php in that order. You can read about it here Using functions.php in Child Themes.
With Genesis we spend a lot of time modifying the parent theme but in many cases we can't modify something that is not yet defined. For example: we can not remove an action in the child functions.php because it is added in the parent functions.php, which has not yet executed.
There are two ways to work around this:
include_once( get_template_directory() . '/lib/init.php' );
genesis_setup
priority 15 (after the defaults at 10).While the StudioPress themes use the first method, I prefer the second.
I understand your point about the added complexity of attaching all the code to the genesis_setup
action.
I wonder if it would make sense to execute the foreach in my functions.php on the genesis_setup
action rather than on the execution of the file. This would eliminate the need to include the functions hooked to genesis_setup in each individual file.
I'm trying out a branch (referenced above) where I hook into genesis_setup
priority 15 in functions.php
and then within that action load the rest of the lib files. This is simplifying the files in lib/
. Props to @bryanwillis for sending me down this path.
This modification has been merged into the master branch. Now functions.php loads all the files in the /includes
directory on the genesis_setup
hook at priority 15.
First, nice theme. I started building my own bootstrap genesis theme, I was shocked to realize yours was the only one out there really. I've been using genesis for about 6 months now after a client made the request. Wish I would have made the switch a long time ago. The semantic markup functions and filters makes it worth it all in itself, in my opinion.
Anyway, to get to the point, I learned most of what I currently know about it from just browsing through the main theme as well as the enterprise-pro theme.
I always thought child themes were suppose to start with :
include_once( get_template_directory() . '/lib/init.php' );
Is there a reason you don't include that? It looks like by not including that you instead use
genesis_setup
I can't quite figure out why this is or what the benefit of one way of doing things over the other is.
It seems complicated because without using:
include_once( get_template_directory() . '/lib/init.php' );
it appears you have to use
genesis_setup
anytime you want to do anything. Can you explain a little bit why you do it this way? Thanks for your help! I'll be sure to link your theme when I get mine all finished.