Build Your Own Business Website header image

Community News Case Study – Part 11 – Add Event Information as Custom Post Meta to Events

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 11th in a series on using WordPress and Thesis as a Content Management System (CMS). In this case study we are creating a community news site. In this lesson we will create custom post meta for the weekend events posts using the Verve Meta Boxes plugin.

Video Transcript

The interesting thing about this next problem is it coincides with the case study that we sort of set aside a few months ago, 2 or 3 months ago and that was the Community News Case Study. And in that, we said, sometime in the future, we’re going to get back to adding events and then we’re going to add event dates and stuff like that. And what we’re going to do here is we’re going to add custom post meta to our events and then we’re going to add a page that lists those events by custom post meta. And then we are going to sort it by custom post meta and then we’re going to also do it by a couple of other things.

And so, the first thing to do is to go to the site that we’re going to use for this. But this is our Community News website and remember, we created custom post types for each of these… for both Seattle and for Edmonds. And we also have a blog. Well now, isn’t that a joke? I asked my wife to put events in for me here so I’d have stuff to play with and the first event that comes up is Dating Workshop for Ages Over 50 and I’m not even sure if she’s hinting at me or what. But in any case, let’s log in to the back side of this.

Now that’s comedy.

Okay and so, just to refresh your memory, we have created 2 custom post types. We have created an Edmonds News post type and a Seattle News post type. And if we come down and look at our custom post types and the custom post type UI and we look at… well, we’ve got these 2 and let’s see, let’s edit one for a second. Okay, here it is. Built in taxonomies and we made the built in taxonomy categories apply to each of our post types. That’s what I wanted to show you.

So what that means then is if you see this, it’s got categories under Seattle News, categories under Edmonds News and categories under posts. And if we go look at our categories, we’ve got this handy dandy category called Weekend Events. And so, this is the category that we are going to be referencing and using.

Okay so the next thing to do and you can see I’ve got 22 posts listed under Weekend Events. So now the way to sort these and display them by event date is to add custom post meta to each of these posts. And we’re going to use Verve meta boxes to create that custom post meta. So if we come over here to plugins and add new and then type in Verve meta boxes, here it is, Verve meta boxes. Again, you can see that it’s installed already. And so, what we’ll do then since I’ve already installed it is come down to its settings and Verve meta boxes can be found under Tools, we’ll select it and I’ve already created the meta box for this. So we’re going to create a test one that we’ll then remove.

So test and we’re going to make this test meta box apply to a post and to Edmonds and to Seattle. But it’s not going to apply to pages because we’re not going to have pages that are events. So we’re going to create that box. If you only have posts then you’ll see a post and a page and you’ll just select your post.

The next thing we’re going to do then is we’re going to add a couple of fields and the 1st field we’re going to add is a date field and the field… we’re just going to call it test date. And under field description, pardon me… yeah, test date. That’s fine and under field description, we are going to say, “Enter the event’s date.” We’ll add that field and then we’re going to add another field which is time. Field name, test time and then we will call that “Enter the Start time for the event.” And we’re going to add the field.

Now, we could easily rearrange this so that the time ended up before the date but we aren’t going to do that. Let’s see, actually you know, what I really want… this is a label. I wasn’t thinking clearly. Test time and this… oh. That’s okay. We’re just going to leave this for the moment. We’re going to add the fields, pardon me. We’re going to give it the right field, we’re going to update the box and then we’re going to come over to our post and we’ll look at our Dating for Over 50.

Here’s our test box and what happens is we can choose the time, start time and date, and we can choose a test date by selecting this little calendar, picking a date. And so, that’s what Verve meta boxes does. Verve meta boxes create custom post meta and then creates a method of capturing it.

Now I’m going to go back to Verve meta boxes though and get rid of that. We’re just going to delete this box entirely because what we have instead is Event Details. So that’s the name of the box, event date was the day of the event. Event time is the start time. If we want to add one more, we could… why don’t we add a venue? So we’re going to add a field type text and that’s going to be venue and we’re going to say “Enter the event’s location.” Add field, okay.

So now we have event date, event time and venue and we’re going to go ahead and update this box and then come back over to our posts. Actually, I’m going to go to Edmonds news posts and I’m going to look for some of my older weekend events because these don’t have anything set. So if I go to Edit Morello Cherry for example… oh, I do have an event date but I don’t have a venue. And for venue, I think what we’ll call it is…oh I don’t know. Edmonds… is this Edmonds, city of Edmonds? Yeah so Edmonds Floral Center and then say save or update.

And so you can see how that works. If we go to another post, Edmonds News post and instead of Morello Cherries, let’s go to… oh okay. I guess it’s going to have to be Seattle News. Go to Weekend Events, Hamlin Oranges, let’s edit that. So event date, let’s put this event date in the past. So we’re going to call it January 15th… let’s see… or we can just make May 15th. Let’s make it my birthday, May 17th at 10 am and the venue will be Hamlin Park. Okay so we’ve got an event date, an event time, and a venue location. We hit update. It’s been added.

So that’s the first part, right? It’s getting a dialogue attached to the posts where you can add a start date or event date, a start time, you can do an end time if you wanted. You can do… I mean, you can add all kinds of things to this. And in fact, in later episodes of this, we are going to add all of the elements to this that goes inside of Google rich snippets event listing. I’m not going to do that today because we’re not going to have time.

But if you go to Google Webmaster Tools or Webmaster Central and let’s see, Help Center and what do we want to find? We want to find Rich Snippets, creating Google friendly sites actually, yeah there we go, Rich Snippets. So if you want to look at…for example, the Rich Snippet type events, if you capture this information properly then Google will… if somebody is searching for an event like you have, Google will return events in this format in their search. So in the future, we’re going to create… take this data, capture it, and then format it in a way that Google create this kind of a search result when somebody is searching for an event. But anyway, that’s just something to keep in mind for the future.

0 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
THIS IS A LIMITED TIME OFFER!
Subscription Options
0 comments… add one

Leave a Comment