Build Your Own Business Website header image

Community Library Website Case Study – Part 25, Add Taxonomy Data to the Teaser

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 the twenty fifth in a series of live lessons on using WordPress and Thesis as a Content Management System (CMS). In this lesson we continue to add data, location taxonomy and topics in this case, to the bottom of the Teaser. We align these on the bottom left with their respective names followed by their lists. We accomplish this with Thesis hooks in custom_functions.php using the_terms() function.

Video Transcript

Rick: Now we’re going to add our location to the bottom of this. So we’ll come back over to this and location taxonomy, okay. So we’re just going to copy this also. No, it’s not going to be all of that there but…paste it. This function adds the… oh no, that’s the wrong one. This function adds the location taxonomy to the end of the teaser. See, once you get started on a project like this you know, lots of the code is iterative. You just keep on working on it more.

So now byob… let’s call it teaser_location and then we may as well just grab this and put it there. And then the hook is going to be Thesis hook after teaser, I think. But let’s just go double check that. Thesis hook after… yeah, I think it’s after teaser box. Let’s see, this hook fires for each of them, right. Okay so it’s Thesis hook after teaser box. Okay and paste that there.

So then we don’t care about call number, ISBN or publication year so we can delete those. And we’re not doing this if it’s single so we can get rid of that and its double bracket. And we aren’t doing publication year, we’re just doing… yeah, so actually I think we can probably just delete all of this. We’re going to have to muck about a little bit with the HTML here.

Okay and so this will byob… let’s just call it teaser location or byob… yeah, teaser-location. And then we’ll get rid of all that extra stuff there plus we’ll get rid of that. Pam is wondering whether or not teaser should be… topics should be in the teasers. Well, we certainly could put topics in the teaser. I’m going to unmute you here for a second. So Pam, where do you think you’d put that?

Somewhere down towards the bottom. I don’t know how it would interact with that location tag but I think it would be a good idea to have the topic in a small font at the bottom somehow.

Okay, okay. We’ll do that. So let’s see, well then I think what we should do is call this teaser bottom instead. Now let’s go back up here and see… where was topics? Okay this function had subtitle author, topic, tags and audience taxonomy. So this is a… oh no. Topics tag, that’s what we’re talking about. So the terms, post id topics and then we could come back down here and post that. Let’s see, echo div and then we should probably… yeah, okay. Let’s cut that out here. We’ll just wrap that in that div, this bottom div. And then what we’ll do is we will add p class equals topics. No, p class equals teaser topics. Okay, byob teaser topics and we need to rearrange these. And then we will echo again and this is going to be the closing p and we’ll have an opening p teaser location and then we’ll have a closing p and then the closing div.

Okay, you want everything width aligned? Let me put you back on here for a second. Okay, Pam? Go ahead. How do you want it?

Pam: Well, I was thinking you could put left aligned to that tag that has the location. Then on the next line, also left aligned, you’d put topics colon and a list of the topics. Something like that.

Rick: Okay do you want to see the name, location and the name of the topics? Or do you just want to see them sitting there? What do you want to see?

Pam: I guess location colon and then the location from. That would make sense and then topics colon and the list of topics.

Rick: Okay let’s see, let’s go look at the terms for a second. You know, it seems to me like there is the term, WordPress. Okay, let’s get the terms. That’s fine. Get terms… it seems to me like there is someplace in here where you can describe how it shows up. So it’s not get the terms, that’s for sure. Term exist, get term, get term by, get term showed on get terms…okay, let’s look for the terms here for a second, the terms. Okay, get the terms. Get term list… where terms in an HTML string of taxonomy terms associated with a post and a given taxonomy. Here we go, so this is it. Get the term list and so we put our post id, our taxonomy name and then we can for example, before and after each one, we could have an LI and a closing LI so each of these things become list items now. And let’s see, well it’ll be an interesting little experiment here. I think this probably even gives me a link…returns an HTML string associated with the post given taxonomy that terms that are linked to their respective term listing pages…right. So okay, let’s try that.

Let’s get the term list and let’s come over here, that’ll be interesting. I’ve never done that. So instead of the terms, we’re going to say get terms and it’s going to be post id and topics, just like that. And then before, we’ll be… let’s see, LI and separator will be nothing. So it’s just that and then after will be a closing LI. Okay so this is going to give us a list of terms as an unordered list. We can go ahead and delete this and then I think we can probably just go ahead and delete that div or I mean that p type.

Yes Pam, that’s correct. You can either make this a comma separated list which is what it is in the other system or you can make them… oh you want to… I’m sorry. I totally misunderstood what you wanted there then. I thought you said you wanted to have them listed on top of each other. So in that case, we don’t need anything here. That’s what happen as we get a comma separated list with the terms.

And then all we really want to do here is switch this stuff around, right? That is, she wants to put the location at the top and the terms… topics at the bottom. So let’s just swap them… topics and then p class… this is going to be teaser topics and this going to be teaser location.

Okay so now, I’m getting the terms location and then I’m getting the topics and before we add this p tag, we’ll start off with an h4 tag or h5 tag, what do you say? And it’ll say topics h5.

Okay so now, what we’re going to have is everything is going to be… well, everything will be to the left if we want it to be or to the left and right or however we want that. We’re just going to take this at the moment as it is and we’re going to upload it and we’re going to test it. Okay so there you go.

So we’ve got location, we’ve got topics and oh isn’t that interesting? So this is actually, this hook is actually not really doing us the desired result because… well, I’m not actually sure why. Let’s see, this one should be here. Why this one has moved over from here to there, I don’t know but I don’t think that’s what we want. So I think that’s probably because of the hook that we chose. Get the term… oh no, no… pardon me. Let’s see, Thesis hook after teaser… let’s see, let’s look at teaser filters for a second. Thesis, no…archive intro, body classes, comments, content crop, header custom loop, next post, previous post… we don’t have any filters for teasers. I thought there was a filter for teasers.

Okay, let’s look at our teaser things here again for a second. Oh, after teaser is what we wanted, not after teaser box. Thesis hook after teaser, that was the problem. Thesis hook after teaser…save the document, upload it, test it. Okay, there we go. Now, we’re getting what we wanted. This one has… it’s in the section of non-fiction. It’s got topics of church history. In this case, the topics are missions and prayer and we’ll have multiple topics. Well, I guess that’s the only one at the moment with multiple topics but you can see the comma there so…

0 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
Subscription Options
0 comments… add one

Leave a Comment