This is the 45th in a series of live lessons on using WordPress and Thesis as a Content Management System (CMS). In this lesson we modify our custom catalog page so that the teaser display inherits the Thesis HTML Structure.
Oh that takes us to step 4 then which now we want to add some HTML structure to this so that it looks decent. And what we’re going to do is we’re going to use the Thesis structure for doing this. Because what Thesis does is it takes posts and or teasers and it groups them into pairs. And Pam, you’re asking… it’s doing that blank spot thing? Yes it is and this step 4 is going to solve that. That is that blank spot that you see is going to go away because of what we’re going to do here.
And so what we’re going to do here… well, actually Pam is asking now and it needs to display all of them not just 10. Yes and actually, that will be another parameter that we’ll have to add to the query because right now, the way it works is if you don’t tell it how many posts to show, it will only show 10 because that’s the way this WordPress site is set up. But we’ll get to that here in a moment.
Okay so the next thing then though is to replace that Thesis teaser with the Thesis HTML structure and I forgot to elucidate what this means that Thesis groups teasers by pairs and it does that by counting the teasers. So essentially goes 1, 2, 1, 2, 1, 2, 1, 2… it’s not exactly like that but every time it hits 1, it does something at the top of the teaser and every time it hits 2, it does something at the bottom of the teaser. And so, we’re just going to steal the Thesis code for that and place it in our code.
And so, we come down here and instead of Thesis teaser, we get rid of let’s see… yeah, we’re going to get rid of that and while. Okay so what happens here is… I missed an if statement. If… so what happens is it says if the teaser count divided by 2 has a remainder of 1, then do this at the top. Otherwise… and make it… make right equals false. Otherwise, do this at the top and make right equal true. And then it says… and then if this at the top is such and such then put the hook in then do the Thesis teaser then close it out and then increment the teasers. Well, right now, this has not been defined, right? Teaser count hasn’t yet been defined so teaser count’s going to be equal to zero until it goes through this once which isn’t what we want to do. So we have to initialize teaser count and so we’re going to say before we hit this loop… but inside of our for each loop… because this is going to happen repeatedly, we’re going to say teaser count equals 1.
Okay so now, we’ve defined a variable called teaser count. We’ve set it to 1, it’s going to go through this process of saying, okay, essentially, is this the 1st teaser? If it’s the 1st teaser, give it the top class. Otherwise, if it’s the 2nd teaser, give it the bottom stuff. And then if it’s… and then again, essentially, says then if it’s the top, put this in the top then if it’s the bottom, put this in the bottom. And then once you’ve done that, increment the teaser count. And then we have this fail safe for when there’s an even number of teasers. That is, after the loop, if the teaser count is an even number essentially, then treat it as if we’re at the bottom anyway. And I’m missing something here… what am I missing for each? Okay and then that next one is if is page and why is that showing me… because I’m missing something here. If… okay, it almost feels like I must be missing a bracket. I was. I was missing a bracket. I was missing… so that’s the big outer bracket and then for each, that is the next bracket. Oh actually… oh yeah, function if for each and that’s what it was. And this was the if… yeah, I was missing a bracket. Okay, I see that now.
Okay so now, when we save this, what we’re doing is we are creating the standard Thesis default behavior for each of those instances of the name. Okay so we’ve uploaded it, now we’ll refresh it. Okay and now we have audiobooks and our audiobooks are nicely organized. And then we have Bible and Reference and those are nicely organized. And that was an uneven number of those so it stopped and it left a nice blank space and then came up Biographies. And again, it was an uneven number and so on and so forth. So now, it’s behaving the way we want it to behave except we do not have any date filtering yet.