Part 1 – How Thesis Uses Custom Templates
In this video we discuss how Thesis uses custom templates. Thesis bypasses the standard WordPress template system in favor of its own. This can confuse people who are accustomed to using and creating custom templates in WordPress. However, the Thesis system reduces a significant portion of server processing which speeds up the loading of Thesis sites.
Thesis also makes creating custom templates a more standardized process than the typical WordPress template system. In this video we discuss:
- How Thesis Custom Template differs from WordPress Custom Templates
- The interrelatedness of Header, Content and Footer
- The connection of the different types and areas of Thesis content elements
As you probably have observed on the website because you know, I talk about custom template somewhat, custom templates in Thesis are quite a bit different than custom templates elsewhere in WordPress. In WordPress, WordPress has a complex method of determining what template should be used under what context and well that’s… and when you enable pretty permalinks that makes the process of selecting a template iterative. So it’s got to ask one question and run through that question and it’s going to ask another question and run through that question. The consequence of which is there’s an awful lot of overheard associated with choosing which template to display.
And so, when Chris wrote Thesis, he realized that he could create a system whereby WordPress does not need to go through that decision making process. Where… and so he completely skips it all together. There’s really only one template that is used. It’s got a couple of helper templates but they essentially do nothing. Though that one template is index.php and index.php does all of the work for every individual version of a template which is not the case with most WordPress themes and is not the standard practice in WordPress. And so the way he does that or the way Thesis does that is that what it does is it… every single instance, every single thing that’s displayed whether or not it’s a single post, a page, an archive, a 404 page, a ‘there is no content on this page’… every single version of a page that WordPress writes follows this pattern in Thesis. It creates the header and the header has a bunch of stuff that it does. It creates the head section of the HTML page. It creates the opening body tag. It assigns a custom class to the body. It adds Thesis hooks. It adds the header, the Thesis default header and it adds the hook after header. And I think it adds the menu.
And so all that stuff happens inside of header and then you get to the content. And that’s where the mean of all of it is which starts off with Thesis hook before content and ends with Thesis hook after content. And then after that content comes to the footer which starts with Thesis hook before footer and then has whatever footer content there is. And then Thesis hook after footer and then Thesis hook after HTML and then the closing body tag. So in a traditional template, the header, whatever happens in the content and the footer, are defined in each template, in one way or another. In the Thesis system, header and footer are defined once and for all. They can be modified but they are defined once and for all and then content is the stuff that gets changed.
And so when you get to content or when Thesis begins to write content, that’s when the template-like decisions get made. When in WordPress, the template decisions are made outside of the boundary of this process right here. So before anything ever begins to render, WordPress is out here trying to figure out what template to use. Well what Thesis does is it draws the decision into this section of the site and uses the same template for everything but varies what happens inside this content based on decisions made here. And this is template-like decision making because it’s not actual template decision making because this is already after the template has been decided. But the first question that Thesis asks is, “Is this a page?” And if it is a page, then it goes off to its standard kinds of behavior for pages. If it’s not a page, it goes to home. Is it a homepage? If it’s not a homepage, then it asks, “Is it a single post?” If it’s not a single post, then it asks, “Is it a category or tagged archive page?” If it’s not a category or tagged archive page, then it wants to know if it’s some other kind of archive. It just goes through that question list including you know, “Is there any content displayed at all?” or “Is there a 404 error?” It asks all of those questions and depending upon the answer to those questions, it behaves a certain way.
Well, the only behavior we really care about is this question of “What does it do if it’s a page?” And so I’m not going to talk very much about the rest of these decisions but if it’s a page, then it asks, “Okay, well if it’s a page, is it a custom page?” Well, if it’s not a custom page, then it asks a question, “Is it no sidebars? Did you pick the no sidebars template?” And if the answer is yes, then it displays only the content column. If the answer is no, then it displays default page behavior which means its content column and the sidebars.
So to help you get a sense of this, I’m going to come back over here to my site and we’re going to look at a page and then let’s see… let’s just look at our Live Answers page. Now under Live Answers, under the template, it’s a custom template. My Live Answers display is a custom template and it displays a custom template that displays custom post types and those custom post types are live answer post types. So it’s a custom template but it could be either the default template, the no sidebars template, or the custom template.
Now archives, that’s a whole different thing altogether. I’m just leaving it out of this conversation. You’d only have one page that wasn’t ever an archives page and it essentially lists everything on your site in a list but that’s not… so it’s completely apart from this conversation.
But this page uses the custom template and so in this decision matrix, it asks, “Is this a custom template?” Yes, so then it goes off under my custom processing. And if it said no, “Is it a no sidebars page?” then it would go do the no sidebars processing. But if it’s not custom and it’s not no sidebars, then it’s default. And if it’s the default template, then it does this default behavior and this default behavior is set up in Design Options. So if you look at your Thesis Design Options, that default behavior really comes down to how many columns and what column order. There’s a slight complication with also which framework are you using but that is sort of a slight complication. It really… but it does come down to those 3 things. Those are the 3 elements of this default behavior – your number of columns, your column order, and your framework – that decide what this default behavior is. And this default behavior actually is translated onto every one of these other choices. And so if it’s the homepage, it’s the default behavior plus the home style content. If it’s a single post, then it’s the default behavior and the content column shows single post content. If it’s a category page, then it’s the default behavior but the content in the category page is category archive content and so on and so forth. So this default behavior gets replicated in each one of these other choices as well, But in this case, if it’s not custom template and it’s a no sidebars template, then it comes down to this default behavior.
Now in order to sort of understand that what that default behavior looks like, I have another diagram on my site. Go to Video Lessons, let’s see… custom templates. Then, this visual diagram of the Thesis custom template area. Okay so I have this illustration here which shows you know, the different parts of the Thesis page. And so here’s that header and everything associated with the header including its hooks and everything else. And then when you select custom template, what it does it, it places this hook in the middle of the template. Thesis hook custom template. And then cuts out all of the other content until footer. Well, this is what the content would ordinarily look like if it wasn’t cut out. It starts off with Thesis a column which has both the Thesis content column and Thesis sidebars on the side of it. And then the Thesis content column has Thesis hook before content and then Thesis hook before post box and then Thesis hook post box top and then you end up with a Thesis page loop which essentially does what’s inside the page including headline area and then the content. And then it has the Thesis hook post box bottom and then Thesis hook after post box and then Thesis hook after content.
This is the sort of the default layout of a standard 2-column page and so if you’re going to replicate any part of the original Thesis HTML then you may insert Thesis sidebars or you may insert Thesis content column inside of your custom template and you would do that right here, whatever parts of it you want.