Intrepid readers may have noticed the link to the “Upcoming Events” on the right sidebar underneath my site search box. What is that you ask? Well, since I’m always posting about shows, and then constantly forgetting about them by the time they roll around, I wanted to devise a way to enter the show as part of a post, and then have it show up magically in a list of upcoming events. So, with that in mind, I created a little hack for WordPress using some php code and the Custom Field Template plugin by Hiroaki Miyashita. If you were wondering how it all works, I’ll give a brief explanation here and a link to all the code you need. First of all download the following two items:

First things first, download and install the Custom Field Template plugin for WordPress. The CFT provides a nice GUI interface for adding metadata to each post which is what drives the event calendar. While you could do what I’m doing without the CFT plugin, it would be much, much more time consuming. Once you’ve got the CFT template installed and activated, you’re going to want to configure it a little in the plugin settings. I’ve got my plugin configured specifically for New York area events, and you can look at download my settings over here, of course feel free to change the options based on where you live. (I think the settings are more or less self explanatory, especially once you look at them in the context of adding a new post.)

Article continued after the jump.

Fig. 2 – Add The Calendar Template and Calendar Page

Once you’ve got the settings configured to your liking, install the calendar.php template in your active theme folder (eg. wp-content/themes/youractivetheme) on your webserver. Then the last thing you need to do is add a new page to your blog (Pages-> Add New) and make sure that “Calendar” is set as the default template. You’ll see this setting on the right hand side of your page (see Fig. 2 above). This is very important, if you don’t set the default template to calendar, the event calendar will not work.

Fig. 3 – Add A Sample Event (aka New Blog Post)

Once you’ve configured the Custom Field Template and added the new Calendar page, there really isn’t a lot to do other than commence normal blogging. Just remember though, the next time you add a post that references a future event, add in the details in the custom fields below the post and voila, it will appear on your calendar page like magic. Events are ordered sequentially by date (dates should be formatted like “2009/12/31” or “2009-12-31”) and only future events show up in the calendar. Past events are still available in the database, and adding an archive page would be easy to do, but right now I don’t really see the need for it.

This event calendar isn’t the most robust thing in the world and it’s not meant to be. It’s just a quick little way to keep of track of shows without having to navigate off of the “add new post” page in wordpress. If you’re looking for something a little more hardcore, you might want to check out the Blogs for Bands WordPress Plugin. If there is anything you can think of that might make this calendar better, feel free to let me know in the comments. Enjoy!

A Final Note: When creating an event, I don’t recommend combining a ticketmaster or ticketweb link together with the “other ticket link” textbox. Just use one or the other, if you use both, two “buy ticket” links will show up under the event. If you choose Ticketmaster or Ticketweb as the ticket provider, the calendar performs an automatic search for your show on the respective site. If your show isn’t sold through the Ticketmaster or Ticketweb, then you should use the “other ticket link” textbox and paste the full URL to the ticket purchasing page.

UPDATE: I just added the code to generate a calendar RSS feed to the download package. To activate the RSS feed on your blog, all you have to do is add calendar_rss.php to your theme and then make a new WordPress page with “Calendar RSS” as the default template.

25 Comments

Just ran across this and it looks like the solution we have been looking for! Thank you for the great post. Question…how does it handle recurring events/dates? Say a particular bar, every Wednesday? Will it show up on the list for all recurring dates or just the initial date?

It doesn’t really handle recurring events at this point, though if you’re handy with the PHP you could probably add some code in there to deal with them in no time at all. It’s actually a great suggestion and I think I’ll probably add it in to a future release (whenever that may be).

One thing, I was able to get the main Upcoming Events page to show up and populate properly, but I wasn’t sure how you created the small right hand “Upcoming Events” sidebar list that links to the main Upcoming Events page.

Hi, this looks like exactly what I’m looking for, thanks! 🙂 I have one question – is it possible to show the present event (exhibition in my case) somewhere? I should have exhibitions page which shows the present exhibition and links to the past and becoming exhibitions.

sorry for this mess, even the “less than” and “greater than” marking doesn’t show up here. Anyway, my modified code shows the event only if the start date is less than/equals today’s date AND the end date is greater than/equals today’s date. Simple really.

Thanks for the post. I used some information here to help me find the solution for a project I’m working on (though I did it a bit differently).

I noticed you are using a comparison in your PHP loop to pick out all items in the future. You can do this much more efficiently by adding a comparison to your query_posts string:
.’meta_compare=>=&meta_value=’. date(‘Y/m/d’, current_time(‘timestamp’)
This will only return posts with date greater than or equal to the current date, so you won’t have all of the earlier posts in your loop. There could end up being a lot of old posts after a while.