Multi Day Event

Image | CC0 pixabay

Custom Post Type Multi Day Event

There are plenty comprehensive Event Calender Plugins available. We could not find one that gracefully handled events spanning multiple days with different time schedules. Let’s write our own then, shall we?

Learn

Keep reading for an explanation on how to go on about it.

Keep reading

The button will take you to a step by step guide through the process.
Continue

Watch

Take a look at what this is all about and see the feature in action.

Go there

The button will take you to a project were we implemented this feature.
Baby Kochs

Download

Get the files from GitHub immediately and for free.

From GitHub

The button will take you to GitHub were the files you need are available.
GitHub

Event Custom Post Type

Events are different to common posts when it comes to relevance. For articles the most recent is the most relevant. Ordering them reflects that: the newest on top, the further down the older it gets. For events the most relevant is the most imminent. The further down the list, the farther into the future we go.

We will need a Custom Post Type to apply a specific list-order to. This post type will have additional fields to store the event schedule of. So first we register our post type in our multi-day-event.php. You can find an in depth guide to custom post types here.

When we have set up our custom post type event, we can reorder its list-display accordingly.

Note that we are ordering our event-posts according to eventdetails_eventday_1. We now need to add custom field to our post type.

Custom Fields for our Custom Post Type

As we want our events spanning up to a whole weekend, we want to store the days/time in special fields attached to our post type. Like this

  • Friday 18:00 – 20:00 | greet and dinner
  • Saturday 10:00 – 18:00 | workshop
  • Sunday 10:00 – 11:00 | breakfast and farewell

This means we need a so-called metabox with our Custom Post Type where editors can enter the event’s schedule. Day 1 will be stored in the above mentioned eventdetails_eventday_1 for sorting lists with our events.

Schedule

We could use that brilliant Advance Custom Fields like always, but in order to not install another plugin and to explore new tools we try the WordPress Meta Box Generator this time. That nifty tool generates PHP code to  add meta boxes and fields to post types OOP style. We then want to hook into manage_event_posts_columns and manage_event_posts_custom_column to display our custom fields in the “All Events” view in wp-admin.

Events

Displaying our Custom Post Type

We now have everything set up to enter and display our Multi Day Events. We can either visually display our schedules by arranging our event-posts like this

Friday 18:00 – 20:00 | greet and dinner

This is a chance for attendees to meet other writers and workshop presenters and catch up with old friends and make new ones. Meals are paid for individually on the evening. There is an a la carte menu and usually a ‘Specials’ board. The Bistro staff would appreciate people ordering soon after they arrive to ensure they don’t have to wait too long for their meals.

Saturday 10:00 – 18:00 | workshop

The workshop affords opportunities for participants to explore the learning diversity movement as an alternative theory and set of practices to learning disabilities, as well as explore how they might create an emergent writing studio space at their school in which teachers and students can embrace this socially just pedagogy.

Sunday 10:00 – 11:00 | breakfast and farewell

Spend the morning after your workshop sharing fun stories of the night before with your closest family and friends. From a basic continental breakfast to an elaborate breakfast, your family and friends will enjoy our award-winning cuisine prepared by our talented culinary staff.

or we could program a shortcode to display the schedule from the events custom fields. Building a seperate archive-template (event-archive.php) or a special single-template (event-single.php) to display your events might be desirable as well. The choice is up to you.

Loose Ends

Taxonomy

If we wanted to add categories and tags to our Events now, we would need to register taxonomies for our Custom Post Type. Be aware though that just registering the existing post-categories for our Events won’t work that well because your theme will probably try to list posts in the category archive, not our events.

Pagination

While we have customized the list-order of our custom post type, the pagination ~ the older/newer navigation below posts ~ will still refer to the publish date.

The poor man’s way would be to order the publish dates of our events. All events could have a published date a year prior to the event date then. Or we could choose the long route rewriting the WP_Query Class.

Leave a Comment

Your email address will not be published. Required fields are marked *