Thesis is a wonderful theme framework, but one of the things I find it lacks is widget areas. Luckily, it’s incredibly easy to create more. First I’m going to show you the code you need to place in your custom_functions.php , and then I’ll explain it all.
The Code
<?php
add_action('thesis_hook_after_header', 'afterheader');
function afterheader() {
?>
<div id="afterheader">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('afterheader') ){ ?>
<?php } ?>
</div>
<?php
}
?>
<?php
register_sidebar(array('name'=>'AfterHeader', 'before_title'=>'<h2>', 'after_title'=>'</h2>'));
?>
The Explanations
That’s not so scary, is it? Nope. Just a few lines of code, really. Here’s what these lines do:
<?php
add_action('thesis_hook_after_header', 'afterheader');
function afterheader() {
?>
This begins registering the function. When customizing Thesis themes you’ll see these lines a lot. First we explain where the widget will end up on the page and then we name it.
<div id="afterheader">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('afterheader') ){ ?>
<?php } ?>
</div>
<?php
}
?>
This creates the sidebar and is not Thesis-specific; it’s a WordPress function. We wrap the widget in a div for easy customizing later.
<?php
register_sidebar(array('name'=>'AfterHeader', 'before_title'=>'<h2>', 'after_title'=>'</h2>'));
?>
This is also a WordPress function. These lines register the widget and then close off our function. We name the widget, which is what you’ll see in your Widget Options Pnale, and then we wrap the title in an h3 tag to match the other sidebars.
More Widgets, Hooks, etc.
You can do this as many times as you’d like. Just make sure to change all instances of “afterheader” to something that describes the additional widgets. There are tons of hooks available for Thesis that you could place your widgets in. Check out the full list here.
If you’d like to put widgets in your footer, Asnio has done a free mod you can download here.
Happy widgeting.
photo by Riebart
Stay Updated

You'll notice this site talks about the Thesis theme for Wordpress. Don't know what the heck that is? Find out.



{ 18 comments… read them below or add one }
Nice article. Thanks for useful info
I hadn’t thought of adding widgets to other areas besides the default sidebars – I’ll have to try it out! Love the simple code.
Alas, copy and paste of code inbto custom-functions.php produces a white screen of death with a syntax error at line 17.
This is Thesis 1.7.
Can you advise?
tnks!
%%robert
@Robert – I just tried it again on Thesis 1.7 and it worked fine. Make sure any functions you have beforehand are closed off. To see if that’s the problem, place this code at the very very top of your custom-functions.php, before anything else. Let me know if it’s still giving you an error after trying that.
@Matt –
Even in online time, that was FAST — tnks!
Followed your advice to the letter. Put it before EVERYTHING. Even before that >? php at the very top.
It worked. There’s the widget area, which I just tested with some dummy text in a text widget.
So I don’t get into trouble again:
This was a totally untouched file. I followed CP’s instructions up at the topwhere he has //Delete this line (etc. etc.). And that’s what gave me the whitescreen of death. SO — if up at the VERY top where it should live permanently? Or is there a better place to keep the file tidy?
So I don’t have to plague you when going further:
1. Adding more areas, just follow your syntax and change AfterHeader stuff to, say Thesis_Hook_Before_Content and give it and new title?
2. Style via CSS for the widget area; with several widgets, insert a break where I want widgets to break to a new line, customize via widget ID and chunks of css?
(I’ve done this in other themes. With CSS I’m pretty brass-knuckle; it’s php that gives me the jimjams, as you’ve seen).
Thanks in advance for the further!
%%robert
P.S. This is an enormous step forward. Lack of widgets elsewhere has really kept me from using Thesis as much as I’d like.
P.S.
Final question!
In your LAST chunk of code up above, how will tbhings change when I do more areas?
tnks!
%%r
You can place it underneath other functions as long as you close them off first with ?> (or take away the <?php opening of this function, but I like all my functions closed off) . If it's totally untouched you can just remove the stuff that's already there like the comments and the function that comes with the theme, unless you're using it.
1. Yes. Just make sure every instance of AfterHeader is changed to whatever other name you want, BeforeHeader for example. Using find+replace in a text editor would work. And then change the hook to where you'd like to place the widget.
2. You can style these widgets just like anything else.
3. Nothing different, just make sure AfterHeader is your new function name.
Hope this helped.
It did, Matt. More than I can say. Tnks *so* much!
%%robert
Hey Matt,
Just thought that you and your readers might be interested in the “Widgets on Pages” plugin I wrote which let’s you add a “sidebar” area to wordpress page and post content through the use of shortcodes. At present it only allows for one widget area but hopefully I’ll udpate this to scale. It’s a nice way to add widgets to any theme without the need to go “under the hood”.
Of course if you give this a go and have any comments please let me know.
This looks like exactly what I needed, but I’m running into a couple of quirks.
I’m also using thesis 1.7, and had to place this at the top of the custom_functions.php file to avoid the white screen of death (not sure what’s missing in the default file to close out CP’s .php there…error message was about expecting a “<" on a line that had no code on it).
I edited to code to create and call a widget called "contentareawidget" that would appear either thesis_hook_after_content_area or thesis_hook_after_content_box. It appeared in my list of available "sidebars" and I was able to move various widgets into it.
But it's not showing up on the site.
Also noticed that when I try to put a plain Text widget into it, I can't actually add any text. When I open that widget inside the sidebar, all I see is the Delete | Close option and the Save button. No fields for title or text.
Any suggestions?
Tony
Tony, are you trying to do this on the Thesis Magazine skin? If so you need to not use < ?php at the beginning and ?> at the end to fix your first error. This tutorial assumes your functions file is blank, and in Thesis Magazine the tags are already open.
Head over to the forums at Thesis Themes and copy/paste your entire functions file and I’ll take a look at it to see specifically what’s going wrong.
Or if you’re using it on a different skin/blank file then let me know.
Hi Matt — this is on the Thesis Play theme.
Here is my custom_functions.php file, with your code at the top.
‘Content Area Widget’, ‘before_title’=>”, ‘after_title’=>”));
?>
<?php
}
require_once(TEMPLATEPATH . '/custom/skins/skins_admin.php');
okay, that didn’t work. Here is a link to the code in a ThesisThemes.com forum post.
http://thesisthemes.com/forum/topic/adding-a-widget-below-the-content-area?replies=1#post-2131
Tony
Hi Matt – just following up to see if you have any thoughts on why the code isn’t working for me. I’ve posted my custom_functions.php file at http://thesisthemes.com/forum/topic/adding-a-widget-below-the-content-area?replies=1#post-2131.
Thanks,
Tony
Sorry Tony! I thought I replied, but I didn’t. That’s definitely my bad. Anyway the code looked just the same as I use (which I can confirm works on a few different Thesis installs), so I’d try to get in touch with the developers of the skin you’re using there.
Sorry I couldn’t be of more assistance.
Great article. I’ve been trying to put an ad rotator in the header for a couple of hours. Can’t seem to find a plugin that works in the header without modifying Thesis code. I thought this might be an alternative. Is it possible to add a widget area inside the header?
The code above works but cause wordpress white screen of death on the thesis 1.8 theme. Any workaround? Thanks.
I found this great plugin and was able to remove the header area with it and replace it with header widget area. I was also able to create footer area with just click of a button
http://wordpress.org/extend/plugins/ultimate-thesis-options/
{ 3 trackbacks }