Pssst. Want us to customize your theme for half the price?
Creating a custom widget area can be the easiest way to insert features across all of your pages, and a huge advantage is that you can now use your widgets to populate that area. As always when editing your functions file, make sure you have proper FTP information so you can access your file if anything goes wrong!
Creating New Widget Areas
I’ve seen a plugin that will let you create new sidebar areas, but it won’t hook them into your layout for you – so you still need to edit your functions file. Luckily, you can create AND place a widget area by just copying the below code into your functions file, and changing all areas that are within brackets.
Example: insert a second sidebar, below the original
OK, here’s some sample code to compare it with:
This example has a number at the end of the add_action code, which is assigning a priority. Basically, priorities just ensure the code is appearing exactly where I want it to, compared to other elements, but I’ll discuss it a little more in a few days.
Example: insert a widget area below every post page
This code has a few extra bells and whistles: it will only show the widget area below a post – pages, the home page, and archive listings won’t show this widget area. I do this by using an if() function and conditional tag. If the result is true, I return which just means I exit the entire block of code and ignore everything that would have come next.
Remember to check your hooks
Remember to check what hooks your theme has and apply your widget to the proper area. My below-post widget code is for HTML5 enabled Genesis themes, so if you’re not on an HTML5 theme you’ll need to use another hook: genesis_after_post_content.
Thoughts? Questions? Comments? I’m here for you!
pssst.. Check out our sister brands!
Leave a Reply