This is the fourth in a short series on creating custom template styles for posts. We will be using Thesis hooks and filters to create these “post templates”. In this part we write the functions that creates the custom sidebars and then adds them to the appropriate post template.
So then the next thing to do is go to step 4 which is to add the appropriate sidebars. And so, in step 4, what we’re going to do is we’re going to register sidebars. We’re going to, again, test that condition if it’s single, we’ll get the post meta, we’ll test the template style and then we will create the dynamic sidebars and add them where they belong.
And if you recall, we are actually going to be creating… let’s see, where did my list go? Okay, we’ve got the default style which is automatically retains its sidebar. We’ll have the no sidebar style which won’t have the sidebars. We’ll have the split sidebars style which will have a sidebar and we’ll have the minimalist style which won’t have a sidebar. So the only time we want new sidebars added in is the split sidebar style. So that’s the thing to keep in mind here as we look at this.
And so again, I’ve started this. The first step is in registering the sidebars. Now, I’ve taught how to register sidebars several times so if this is Greek to you, just look up on the site how to register sidebars. But the point I want to make in this is that we’re going to name one sidebar, post split sidebars left sidebar and we’re going to name the other one post split sidebars right sidebar. And these are going to show on our widgets display so we can drag widgets to them. And then on top of that registering the sidebar, we’re going to create the dynamic sidebars.
And so, here’s where we again, grab the global post, ask if it’s single. If it’s single, we go get the template style with the get post metaand we have to put that again, post meta type in here. So that is the post style selection. And then we want to ask, if this byob post template style is equal to split sidebars, right? So we come back up here and we say if it’s equal to split sidebars then we’re going to add the dynamic sidebars. And again, I have taught several times how to create a dynamic sidebars so I’m not going to really go through it much except to say that because we are splitting the sidebars, I have put one of the sidebars inside of div id sidebars. And the other sidebar, I have not because we’re going to add these both in the same location but we’re going to use CSS to float one left and float the other one right. And so, they can’t be wrapped up in the same div because they won’t… it won’t split across the content.
So the one thing that is left for us to do here though is to hook it to the correct place and we are going to hook this before content. So that is add action Thesis hook before content and then comma space single quotation marks and then it’s this byob split sidebars semi-colon. Okay now, we are going to add that to before the content so what you’ll have conceptually is sidebar… well, I’m just going to sketch at the top of this just so you understand what I’m saying.
Conceptually, what you’re going to have is sidebar 1 and then left sidebar and then the content and then right sidebar. Although, in this illustration, both the left and the right content are being… let me select a different color for this… are being inserted right here. So that Thesis hook before content is right here and then when we insert these, you would think of them as being sitting side by side before the content and so, theoretically, this one and then this one and then this beside it. But what we’ll do is we’ll use CSS to float this one to the right so that it goes to the other side of this. So that’s what’s coming up next.
And I’m actually just going to late on this so that I can finish this one because tonight, we have plenty of stuff we’re talking about so anyway, I’m having too much fun with this. We’re going to go ahead and erase all that silly stuff. And I’m going to save this and we’re going to upload it and we’re going to come back over here to our Van Black Cherries which is, I believe, the one we made as our… oh no, this was our minimalist, wasn’t it? So let’s go to the split sidebars which was the Bing Cherry.
Okay so now you see it has right sidebar, post split sidebars, left sidebar and if we go to our widgets panel for a second, you can see that our widgets panel now has post split sidebars left sidebar. This is the widget area for the left sidebar split sidebars post style and this is the widget area for the right sidebar of your split sidebars post style. We’re going to create the custom CSS which allows this stuff to go where we want it to go and we’ll get to that here in just a minute.