Props to Carrie Dils for inspiring the title of this post!
In my free time (ha!) I volunteer in the StudioPress support forums, where users of the Genesis framework can request help with designing and customizing their websites. People often need help using and understanding Genesis hooks, and while a Google search will turn up a number of resources, I think some of them are just plain hard to understand.
What Are Genesis Hooks?
Think of your Genesis site’s structure as a map. No matter what child theme you’re using, there are certain areas included in all Genesis sites – header, primary and secondary navigation, content area, sidebar, footer, etc.
Note: Hooks are not unique to the Genesis framework – they exist in all WordPress websites. However, Genesis has its own hooks that are basically the same regardless of what child theme you use. If you work with Genesis regularly, it makes sense to know and understand the hooks it uses so you can apply changes to any child theme.
For each main section of your theme, there are hooks you can use to target that area for customizations, kind of like sticking a pushpin on a map. For example, let’s say I want to put an image above the content of every page on my site. I would want to “hook” or attach it to a spot on the map that is after the navigation but before the content area. The hook I use depends on where I need a certain object or bit of content to show up.
Hooks are generally used to make structural changes to your site. If I just want to add an image to a blog post, I don’t need a hook for that – I can plop the image into the post editor. But if I want something to show in a certain spot on every page of the site, or on multiple pages of the site, a hook is a good way to do it.
Why Would I Use Genesis Hooks?
Here are a few situations where it might make sense to use Genesis Hooks.
To add a new widget area to your site. Maybe you want to add a widget area to the bottom of all your blog posts so you can put an opt-in for your email list there. To do this, you would need to use a Genesis hook to tell the widget area where it needs to show up. In other words, if your site structure is a map, you’re sticking a pushpin on the area at the bottom of your posts.
To change the structure of your site. If your child theme places both navigation menus (primary and secondary) under the header, you may want to show one of them above the header instead. You can use a function to unhook the nav from its current location and hook it in a different place.
To places ads in certain places. Have you ever needed to put an advertisement or banner in a specific location, but didn’t know how to get it there? My clients have this problem a lot – an ad rep says a banner needs to be above the header or right before the footer, for instance, and they email me going, “Um, how in the world do I do this?” With Genesis hooks, that’s how!
How to Use Genesis Hooks
Now you know what Genesis hooks are and a few potential uses for them, but how do you actually use them on your site? There are two main ways to do this – the one you choose depends on your preference and level of comfort with editing theme files.
Method #1: The Genesis Simple Hooks plugin
For the average Genesis user, I recommend the Genesis Simple Hooks plugin. It gives you a settings page with every single Genesis hook listed (meaning you don’t necessarily need to memorize what hooks are available). There’s a box under each hook where you can paste HTML, PHP, and/or shortcodes.
One advantage of using the Simple Hooks plugin is the ability to maintain your changes no matter what child theme you use. So if you switch to a different child theme, your ad code or after-post widget area will still be there. However, if the code you paste in is missing a character or causes a PHP error, you may have to deactivate the plugin via FTP to get back into your WordPress dashboard.
Method #2: Editing functions.php (or creating your own simple plugin)
This is my preferred way to use Genesis hooks, though that doesn’t necessarily make it better than the Simple Hooks plugin. There are certain changes I make to almost every site I work on, so I either upload the standard Genesis functionality plugin I created or paste all the functions from it into the child theme’s functions.php file. For me, this is faster than scrolling through the Simple Hooks options and finding the hook I need.
This method also has the potential to “break” your site, meaning you need FTP or File Manager access in case something goes wrong. Any functions you add to functions.php will be specific to that child theme, meaning you would need to add them again if you change to another child theme later.
How Do I Know What Code to Use with Genesis Hooks?
So you’ve installed the Simple Hooks plugin and you’re itching to use it. What kind of code do you use, and where do you get it?
When it comes to customizing Genesis, Google is your best friend. There are thousands of tutorials available for everything from adding widget areas to putting in banner ads. Here are a few good places to find code snippets:
- The Genesis Visual Hook Guide – essential for working with hooks
- StudioPress Tutorials – a list of tutorials for common Genesis customizations
- Genesis Snippets – a reference site containing tons of code snippets
HIGHLY RECOMMENDED: This video from BobWP shows the Simple Hooks plugin in use. This is the single best way to understand how this works if you’re still unsure.
What questions do you have about using Genesis hooks? Have you made any cool customizations to your site with the Simple Hooks plugin or functions you’ve added to your theme? I’d love to hear from you!