Build Your Own Business Website header image

How to Create Custom Templates for Posts – Part 7 Create the “Minimalist” Post Template

Difficulty Level -

Filed Under Topics - , ,

Listed Under Lesson Subjects -

Applies to -

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

This is Part 7 of the series, How to Create Custom Templates for Posts. We show the codes we need to have in order to remove the sidebars, nav menu, comments and footer leaving nothing but the post content.

Video Transcript

Pardon me, custom templates for posts. So I think we did, yeah 6 pieces to this so there’s 6 videos in that series. We’re going to add a couple more tonight or yeah, at least one tonight. And the reason why we’re adding that is because the code that I created for this you know, we had 3 different templates that we created for posts. We did the no sidebars template, the split sidebars template and what was supposed to be the minimalist template.

But unfortunately, the minimalist template didn’t really take everything off of the page. And let’s see, is Sean still with us? Okay, Sean’s still with us because Sean, this is going to segue into the question that you asked last week that I actually answered last week when you were gone but then I totally screwed up the recording and the recording didn’t work. Well actually, it worked but there was no audio.

And so, I’m going to redo that but we’ll talk about some of those concepts here in this part. And to refresh your memory, we come over to our blog page and the post in question was this Van Black Cherries post. This was the post that I had created and gave the…selected as a minimalist template.

So if we look over at post for a second and we look at that Van Black Cherries post, we selected the minimalist template here, right? If we went to the default template and hit update and then refresh this you know, now it just looks like a normal blog post. But instead, what we want is the minimalist template and the minimalist template should remove the sidebar, remove the header and the nav menu, remove the comments, remove the previous post and next post stuff and remove the footers. So all that it is is the content and the you know, heading and the post image and whatever else it is you put in there.

And the only reason why this isn’t that way now is because I didn’t really include all the code to get there. So if we update this and refresh that, now let’s actually fill out the code that it needs in order to get to that point. If we come down here to look at our function, we had a function here that said you know, if it’s single and if the post template style and then you get the post template style from that meta box that we looked at and then it says if the post template style is minimalist then do some stuff. And what we want to do is we want to remove the header, remove the sidebars, remove the footer and you may remember that we remove the sidebars automatically, I believe. Add filter Thesis show sidebars if… yeah, right. So here’s where we remove the sidebars in this position. So we don’t need to remove the sidebars again but we do need to remove the header and we need to do a better job of removing the header and we need to remove the nav menu and then we will need to remove comments and next and previous links.

So the way we’re going to do that… and I had posted some code actually. We’ll come over here back to the code for a second. I posted some code on the forum about this but when I posted that code, I didn’t really translate it into this specific example. And so, it just sort of sat there but it wasn’t really modified to fit this example. And that code was here but we’re going to take all that code now and come back over to this page and add it only because I want to copy from it. Because I have this byob show footer byob show sidebars which I don’t care about so I can remove because I’ve already got that taken care of and byob show header show footer… yeah, I’m going to pull this out of there.

So we’ve got our show header and show footer and this is using the Thesis filter. The Thesis filter that we’re using is Thesis filter show footer show sidebars show header and when we add this function to that filter when return false to that filter, what it does is it doesn’t display the footer and it doesn’t display the header.

So I’m going to just grab these 3 pieces of that code and I’m going to let’s see, replace these 3 pieces. Okay so I’m not going to show the footer then show sidebars has already been dealt with. We’re not going to show the header and I can now delete this and we just need to do this for a couple of other things.

So let’s go over to the DIY Themes for a moment and log in. Go to the User Guide, go to Filters and then we are looking for the next previous links. Actually, you know what I should really do is actually just search for post navigation here. Okay well, did I say post navigation? I did, didn’t I? The last time I did this, it returned the correct results and that’s not it. I think it’s actually… let’s see, let’s say default functions. Well, Thesis default functions. Wow, it’s not giving it to me.

Okay previous and next post links… okay so I can remove that. It sayson single posts… okay so in order to remove the previous and next links, we would use the remove action and then Thesis hook after content and then Thesis previous next post. So that’s the piece of code I need to grab for that here and that’s the previous next post and then I need to get rid of the comments.

And so, we’ll go back over to here and we’ll go back to the Table of Contents, I guess, and browse back down here to comments. Let’s see, where’s the remove comments? Let’s see, I think yeah, Thesis comments link is the function and so we’re going to remove action Thesis hook after post and then Thesis comments link. We’ll go ahead and take that one and paste it there.

So now, we should be getting rid of the footer, the header, the next and previous posts link and the comments. And if we save the document…Larraine… and then upload it, here’s the moment of truth. What happens now? We have an error. Custom functions php line 254… what does it say? “Cannot redeclarebyob show footer”, okay I’ve got that silly thing in there twice. Where? Oh, got both of them in there twice, show header and show footer are in there twice.

Okay, save the document, upload it and refresh it. So I guess this now needs to be removed via the post itself. So I’m on the post now, I could down here to the bottom. “Discussion is not turned on.” So if you go to Screen Options and drop down and then turn on Discussion, I can come down here and say, “Don’t allow comments” and “Don’t allow trackbacks”. And then say update and then refresh this.

Okay, I must have failed to remove that link and this must be the category it’s in which is I think, in Design Options and if we look at posts, let’s see…content area, headlines, bylines, post meta… I think that’s… no. Comment options… okay if we turn off trackbacks for a second… comments… that might help. That was it.

So once we pulled that out of there, now we have you know, essentially the equivalent of a no sidebars template with nothing on it except for the post content.

0 Comments… add one
0 comments… add one

Leave a Comment