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.
Community Library Website – Case Study Part 2 – Create Custom Post Types
Community Library Website – Case Study Part 3 – Custom Post Type Configuration
Community Library Website – Case Study Part 4 – Custom Taxonomy Decisions – Theory
Community Library Website – Case Study Part 5 – Custom Taxonomy Decisions – Practical Application
Community Library Website – Case Study Part 6 – Incorporating Existing Data Into the Project
Community Library Website – Case Study Part 7 – Creating Hierarchical Custom Taxonomies
Community Library Website – Case Study Part 8 – Creating Non-Hierarchical Custom Taxonomies
Community Library Website – Case Study Part 9 – Creating Custom Post Meta
Community Library Website Case Study – Part 10a – Restore the Database Using BackupBuddy
Community Library Website Case Study- Part 10 – Creating Custom Post Meta – Continued
Community Library Website – Part 11 – Importing Existing Data to the Website
Community Library Website – Part 12 – Prepare Existing Data for import by the CSV Importer plugin
Community Library Website – Part 13 – Import Existing Data Using the CSV Importer Plugin
Community Library Website – Case Study Part 14 – Date in Permalink Configuration
Community Library Website – Part 15 – Importing Images
Community Library Website – Part 16b – Final Data Import
Community Library Website – Part 17 – Add Thesis Post Meta to Custom Post Type
Community Library Website – Part 18 – Add WordPress 3.0 Menus
Community Library Website – Part 19 – Add Post Meta and Taxonomy Information to the Post Display
Community Library – Part 20 – Add topics and audience to book display
Community Library – Part 21 – Display the Rest of the Post Meta in the Post
Community Library Website – Part 22, Create the Permalink Structure
Community Library – Part 23 – Remove Custom Post Meta from Post Display
Community Library Website – Part 24, Add Taxonomy and Post Meta Data to the Teaser
Community Library Website – Part 25, Add Taxonomy Data to the Teaser
Community Library Website – Part 26, Adjust the Teaser Styling Using Design Options
Community Library Website – Part 27, Styling the Teaser Using CSS
Community Library Website – Part 28 – Fine Tune the Teaser Display
Community Library Website – Part 29, Designing a Custom Catalog Page
Community Library Website – Part 30, Using a Query String in a URL
Community Library Website – Part 31, Adding Custom WordPress Menus
Community Library Website – Part 32, Add Custom Menus to the Catalog Page
Community Library Website – Part 33, Add Another Custom Menu to the Catalog Page
Community Library Website – Part 34, Troubleshooting Custom Menus
Community Library Website – Part 35, Add Styling to WordPress Menus
Community Library Website – Part 36, Add HTML Markup to WordPress Menus
Community Library Website – Part 37, Add WordPress Menus to Archive Pages
Community Library Website – Part 38, Add and Style a List of Tags
Community Library Website – Part 39, Add a Search Box to the Sidebar
Community Library Website – Part 40, Add Links to the Sidebar
Community Library Website – Part 41, Add Taxonomy Drill Down Browsing
Community Library Website – Part 42, Custom Loop to Display Custom Post Types
Community Library Website – Part 43, Simple Custom Query
Community Library Website – Part 44, Custom Taxonomy Query
Community Library Website – Part 45, Add Thesis HTML Structure to Teasers
Community Library Website – Part 46, Display Posts from the Last 60 Days
Community Library Website – Part 47, Custom Loop If Have Posts
Community Library Case Study – Part 48, Increase the Number of Posts that Display on the Custom Catalog
Community Library Website – Part 49 – Naming Conflicts in Custom Taxonomies
Community Library Website – Part 50 – Find and Replace Semi-colons in the Database
Community Library Website – Part 51 – Modify Taxonomy Names Directly in the Database
Community Library Website – Part 52 – Sort Posts by Meta Value
Community Library Website – Part 53 – Show the Term Label Only when a Term Exists
Community Library Website – Part 54 – Sort Archive Posts by Meta Value
Community Library Website – Part 55 – Add Sort Order to Custom Taxonomy
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…