Quantcast
Channel: Custom Post Types – Build Your Own Business Website
Viewing all articles
Browse latest Browse all 10

Custom Post Type Case Study – Part 6 – Add Thesis Post Meta to Custom Post Types

$
0
0

In this session, we show how to add Thesis Post Meta to the Custom Post Type that we created. The code that we use to add the Thesis Post Meta to the custom post type is displayed here above the video.

[This post contains video, click to play]

Code used in this lesson

function thesis_for_custom_post_types() {

$post_options = new thesis_post_options;
$post_options->meta_boxes();

foreach ($post_options->meta_boxes as $meta_name => $meta_box)
{
add_meta_box($meta_box['id'], $meta_box['title'], array('thesis_post_options', 'output_' . $meta_name . '_box'), 'court-cases', 'normal', 'high'); #wp
}

add_action('save_post', array('thesis_post_options', 'save_meta'));
}
add_action('admin_init', 'thesis_for_custom_post_types');

Video Transcript

Rick: Actually, I’m going to just get this stuff in. The one other thing I’m going to do tonight because we’re already over here, the one thing I would do tonight is add the custom code for the… to include the Thesis Options or the Thesis post meta.

Reese: Okay.

Rick: So we’re going to do that next except I need to… let’s see…

Reese: Any word on Thesis 2.0? Or is that a sore subject?

Rick: Oh, it’s not a sore subject. Not to me, anyway. I mean, I believe that it’s quite a ways out. I’m pretty sure that it’s… it’s not going be out by the end of March, I don’t think, based on past history. Although 1.83 is supposed to be out here pretty soon so… okay and so this is court cases. No, post types.

Reese: Or custom post types. Yeah, I think you missed a ‘t’ between post and type.

Rick: You know, I think I did too. What did I really call this thing though? Custom post is what I called it. I knew I didn’t have 3 words in there. Custom post, not that that really matters that much here but… let’s see. Let’s come over to Advanced…

Reese: So when are you going to make a pilgrimage to Oklahoma so I can buy you that steak I’ve promised you for so long?

Rick: Steak sounds good right about now. I haven’t had dinner yet so be talking like that yet. Let’s see…

Reese: (02.20)

Rick: Exactly. We’re just going to go to test here for a second because I think wp content, themes… yeah okay. We’re going to go test. And then instead of Laurraine, it’s going to be post type. No, custom post. Connect it up… okay, perfect. Oh, that’s not right. Pardon me. Let’s fix that. Custom WordPress… okay, connect. Okay, wp content, themes, thesis_182. It’s going to download the site here. Let’s rename this. Custom, rename this one custom and then open up the file in Netbeans. Come on, baby. You can do it. Open file. And obviously, we’re not going to get done tonight but we are going to get it set up so that you can start entering your data.

Reese: If you’ve got the other code, I can drop some of that in if you want to…

Rick: Actually, I was really waiting to understand what you wanted me to do with this stuff before I wrote the other code so I haven’t actually written it.

Reese: Yeah, last week was kind of a weird week. We had to make (04.48) rush to Dallas for a funeral so…

Rick: Okay, where did test… oh, there it is. Test, go to content, themes… no, that’s not the test one. Here it is. There are so many silly websites that it’s hard to keep track of where I’ve got what. Okay so what we’re going to do then is we’re going to take this code from my site… content and I think I have that under custom functions. Maybe not, let’s see. Custom taxonomies is a… yeah, I think this is it. Post meta for… no. Okay, register post types, Thesis custom post types.

Reese: Did you call your congressman today to register your…

Rick: Actually, I did not. I didn’t.

Reese: Your displeasure with SOPA and TUPA?

Rick: No. I did send an email but I didn’t call.

Reese: I think (06.40) backed down so it may be crashing and burning. We’ll see.

Rick: That would be interesting. Okay, Thesis for custom post types. And so this is just essentially making those meta boxes work for this except we have to get the right name here and it’s not answers. It’s court cases.

Reese: That’s the name of my custom post type?

Rick: That’s the name of your custom post type, court cases. And otherwise, that’s all we had to do with that function.

Reese: They can use cut and paste that I guess and…

Rick: Yeah. I’m going to… I’ll post this on the forum here, under Live Answer code so that you know, you have access to that.

Reese: Great.

Rick: But then we’re just going to upload this and as if by magic, we are… when we go over to the head of this thing, we will now have SEO details and additional style meta keywords and all the rest of that stuff. Okay so next week, what we’re going to do then is write the shortcode that creates the result. Now, what you may want to do… I mean, we could decide today what that shortcode looks like even though it’s not written yet, if you want.

Reese: I think you told me that it would be like long or gti-long and then that was actually the function name.

Rick: Gti-long and then we’re going to have the parameter.

Reese: If we do the shortcode 1925-mckenna, 19…

Rick: 1925-mckenna.

Reese: No ‘a’ in mac.

Rick: And the reason I’m really doing this is just so that we document how to create the shortcode because it’ll be gti-long or gti-short, right? And either of those ones will give you the long version and it will either link to the internal post, link to nothing or link to an external resource.

Reese: Right. And basically, what’s it’s going to… now on that gti-long, I guess that’s going to have the anchor tag stuff?

Rick: What do you mean? The site tag?

Reese: Yeah. Well, not just the site tag but the href, a title… you know title equals…

Rick: Only if you…

Reese: Put that in the full reference?

Rick: No, only if we… are you saying you want to specify a custom title for each one of these links?

Reese: Well, I want to be able to hyperlink back to that page. So if they hover over it… let’s see here. Let me see if I can find one.

Rick: Well, the link is going to work without a title. The link will work because we’re going to create the link inside of php when we query our function. So the link is going to be you know, the post… the link to that custom post. And that’s going to… we’ll have that part working just fine. But.. and the best thing to do is automate it so that it automatically selects and we can automatically create a title for it so that the title is when you hover over it is you know, “Go to… on this site” or “Go off site to this resource” or whatever, you know,

Reese: See… let’s see if I can find one. Okay if you go the gamblingtaxinstitute.com website now, I have a case called Frey.

Rick: Okay.

Reese: In the search box over the top, I don’t have that part working.

Rick: Oh, Frey.

Reese: Okay, Appeal of Frey. If you scroll down, I hope your mouse doesn’t work on… my mouse doesn’t work on your screen. You’ll see an Appeal of Frey down towards the bottom, a little more. See, right there? So when you hover over Appeal of James P. McKenna, see how it comes up and it says Appeal of McKenna 1BTA? So that’s the part of the anchor tag stuff.

Rick: That’s fine. When we go to write that code, you’re just going to have to tell me you know, what specifically you want to use as the title then.

Reese: Right. And basically, that’s the same as the full reference. The only difference is in the title, it doesn’t let you use the site tag.

Rick: Yes, so what we’re going to do is strip the site tag. That’ll be an interesting little challenge. Simple but interesting. We’ll strip the site tag out of the results before we make it into a title.

Reese: Okay. See, I only call you when I’m stuck, when I’m really, really stuff.

Rick: You know, this is a fun problem. I’ve really enjoyed you know, thinking about it and I’m enjoying presenting it because it is really an interesting problem. You know, there may be a limited number of people who are interested in the solution. But the concepts underlying the solution, I think, are compelling and it is kinda of esoteric but…

Reese: Well and if you think about it, if you’re really going to use WordPress as a Content Management solution, as a true CMS, I mean, you’re going to be referring to other pages in your database.

Rick: Yeah.

Reese: I mean, from a Content Management System, this isn’t that far off.

Rick: Well, from a Data Management System also. You want to be able to manage, you want to be able to manage the data and that means you need a system in which the data is only entered once and then used as many times as necessary.

Reese: And that’s why it was kind of making me nervous because you know, in the Cohan case, I only have… or in my Lady Luck Diary website, I only have 40 something cases. But that one Cohan case was mentioned 14 times in 14 other cases and articles that I’ve written. I mean… and what are the chances that I’m going to misspell something or get that citation wrong and it’s you know, in the deep, dark recesses of… or something and I’ll never find it or know about it. So I want to try to be as accurate as possible. But…

Rick: And from a programming standpoint, WordPress actually makes it very easy to do this. What we’re doing tonight is actually very easy programming. It may seem complicated to people who are just learning how to build their own websites but from a programming standpoint, this is very easy programming and I’m going to look like a real idiot if I can’t make it work right. But…

Reese: Not to me.

Rick: But it’s because… it’s easy because it’s WordPress. If it wasn’t in WordPress you know, we’d have all kinds of other things that we’d have to deal with. But WordPress handles all of the data acquisition and management for you and so all we have to do now is decide what data we want to capture, decide how we want to reference it and then fit it into WordPress’ system. And that’s the beauty of this problem really, is that is it shows all the power of WordPress and it you know, it may not seem like it’s a big of a deal if you don’t really know what’s involved. But really, WordPress is extremely powerful because it automates so much of this that all we have to do is just write a few pieces of code and it all comes together.


Viewing all articles
Browse latest Browse all 10

Trending Articles