Community Forums › Forums › Archived Forums › General Discussion › Using functions file instead of Simple Hooks
- This topic has 4 replies, 2 voices, and was last updated 10 years ago by Brad Dalton.
May 26, 2013 at 6:52 pm #42739
I have been using Simple Hooks for a while but would really like to know how to write these into the functions file. I have read Nick the Greeks Genesis Explained series, which still remains all Greek to me as it is obviously over my level of programming comprehension. I just read, comprehended and implemented a great tutorial on creating and placing a widget via functions - http://wpdaily.co/genesis-hooks/
This is the type of tutorial or explanation I'm looking for. Does anyone know of one or can explain how to do this in a simple fashion?
May 26, 2013 at 11:39 pm #42760Brad DaltonParticipant
There are 2 differences between pasting PHP code into the Simple Hooks field and using the same code in a custom function in your child themes functions.php file.
1. Firstly, all PHP in simple hooks needs to be wrapped in opening and closing PHP tags
2. Secondly, PHP in simple hooks doesn't include any of the genesis_hooks in the code because the field already outputs your PHP using that hook.
Example: If you want to display a slider on the home page using Simple Hooks, you would paste this code into one of the genesis_hook locations. Most likely, the genesis_header hook.
You could do exactly the same thing using a custom function in your child themes functions.php file and this is the code you would use.
You can clearly see both code snippets include the tag for the slider however the difference between the 2 code snippets is this:
The second code snippet includes the genesis_header hook in an add_action which hooks the slider into the header hook position and isn't wrapped in PHP tags as the tags are already included in the functions.php file.
Its also includes a function using a unique name which describes what the code does. This must be different to the names of all other functions in Genesis and your child theme.
May 27, 2013 at 10:12 am #42808
Thank you so much for your clear and informative reply. I am now starting to "get it" - yeah! I have also bookmarked your site and code snippets.
May 27, 2013 at 2:40 pm #42828
One question, what is the reason for adding
May 27, 2013 at 9:35 pm #42861Brad DaltonParticipant
If the Easing slider plugin is installed, then execute the code and display it in the hook location.
- The forum ‘General Discussion’ is closed to new topics and replies.