The following tutorial is based on the Genesis Framework and may be advanced for some readers. My tutorials are based on my own experiences in learning Genesis so I would love some feedback. If you are not familiar with PHP code, I do not recommend making any changes to your functions.php (unless of course you have a back-up of your functions.php and you know how to restore it). One small typo could wipe out your site so proceed with caution….
Hi everyone! Today I wanted to show you how I added a widget before my footer. The reason I wanted to do this was to be able to have an optin form in that area to show up on all pages to increase my number of leads, however you can use this technique to put whatever you’d like in your new widget.
As I mentioned earlier, this is a Genesis-specific tutorial which includes two parts: registering the new widget area and telling WordPress where to put it on your site.
Registering a Widget Area
First thing we need to do is register a widget. Here is the code I used in my functions.php file:
These are basically 3 parts to this code:
- The “id” must be a unique ID and uses all lower case but no special characters, or spaces. You can use numbers if you’d like.
- The “name” is more flexible, you can use spaces and other characters. This is the name of the actual widget that you’ll see in the dashboard.
- The “description” is used in the dashboard to remind you what the widget is for.
You can register an unlimited amount of widget areas in your theme but keep in mind that the “id” has to be unique – this is very important!
To make sure it worked, I head over to my widgets to see if it is listed…yay! It worked!
Displaying the Widget
Next, I need to place that widget in my theme. As I mentioned earlier, I want to include it everywhere on my site so here is the code that I added to my functions.php file (this tells WordPress to hook this in the Genesis before_footer hook):
I’m using Magic Action Box to display a horizontal optin form in my widget. See my tutorial on “How to Create a Horizontal MailChimp Form“.
If you need some help setting up a new widget area on your site, drop me a line!