Build Your Own Business Website header image

Case Study Part 8 – Add Thesis Meta to Custom Post Types

Difficulty Level -

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 eighth in a series of live lessons on using WordPress and Thesis as a Content Management System (CMS). In this case study we are creating a community news site.
Here we discuss how to enable the Thesis meta in the custom post types in the community new website. Thesis meta enables the Thesis post options such as SEO Details and Additional Style.

Video Transcript

There are a couple of things I want to do about this Community News site. The first one is to go back over the 8th part of the lesson which is something that I haven’t… I thought I had recorded but evidently failed to do so and that was the part of the lesson that talked about the code that gave the custom post types the Thesis meta information and so just to remind you, I’m going to go back over here. I trust everybody can hear me okay, I think I’ve got this sound set up right but not absolutely certain it’s working the way I like it to be.

So anyway, if we go ahead and look at the different custom post types, we’ve created two – Edmonds News and Seattle News – and under Edmonds News, if we open up one of our Edmonds News posts, you can see that we’ve got the SEO details and additional style and post image and thumbnail and javascript and so on and so forth. We’ve got all of these things that are part of the Thesis meta and we added that to these posts by using a piece of code. So I want to open up that code here real quickly and just walk through that with you so that we can have this part 8 in our system. Part 9 has already been posted. Part 10 – we’re going to finish off tonight and so I’m going to let’s see, open up a file here and where are we? Website… byobwebsite. Tutorial site? No, that’s not it and then community… yeah. WP content themes thesis_18 and custom functions_php. So here in our custom functions_php file, we have this function here which adds the Thesis meta boxes to the custom post types. And so the very first thing we’re doing is we’re calling this function and I called it “Thesis for custom post types” and the first thing we do is a couple of Thesis elements called post options.

So we call those post options we say that we are going to do a new set of these Thesis post options and then we want to talk about the post options, the meta boxes that are part of those post options. And then so for each meta boxes inside of post options, we’re going to create a meta box in this custom post type so it’s add meta box and then these are Thesis specific stuff meta box id, meta box title, so on and so forth. Meta name, the part here that’s important to know is this is where you put the name of your custom post type. And so this custom post type here was Seattle and this one was Edmonds and so this is the function that adds those Thesis meta boxes to the custom type Seattle and Edmonds. And then, the interesting thing about this is that we… first we add action to the hook which is the save post hook and in that save post hook, we are adding this array – Thesis post options and save meta are both functions in Thesis that have already been defined and so we’re just refreshing them or reusing them. And then finally, we’ve got this final add action and that add action is adding to the admin_init hook and this is where we are calling our function here, Thesis for custom post types. So this sort of introduces 2 other hooks, these are WordPress hooks – save post and admin_init and then the Thesis post options and save meta are 2 Thesis functions that are defined elsewhere in Thesis and they’ re essentially the same thing as this. It’s a function like that.

Okay so anyway, this is what we did in order to make that show up the way we wanted it to show up.

2 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
Subscription Options
2 comments… add one
  • John Antonacci September 27, 2011, 10:35 am

    Is there code posted for is video and all the videos from this series?

    • Rick Anderson September 27, 2011, 11:57 am

      Yes John, the code for the Live Answers is found in the forum called “Live Answer Code”.

Leave a Comment