Events Custom Post Type Proposal for Multisite

This is intended for the series of blogs.  There are a number of needs, from weekly chat schedules for some Make blogs, to WordCamps for others.  Each site needs to be able to display their own events, and the main Make site would need to be able to display an aggregate of all (or some) of the sub-sites.

I see the implementation of the output (data structures will be addressed separately) being done via a shortcode, as follows:


which would do stuff roughly like:

$events = Super_Spiffy_Event_Calendar::get_events();
Super_Spiffy_Event_Calendar::render_plugins( $events );

Not really tricky.  That will display any events from the multisite blog that you happen to be on.  However, for the aggregate, I see something more akin to this:

[super-spiffy-event-calendar blog_ids="2,3,4,5,6,13,14,19,22"]

which would be more akin to:

$original_blog_id = get_current_blog_id();
$events = array();
foreach ( $blog_ids as $blog_id ) {
	switch_to_blog( $blog_id );
	$events = array_merge( $events, Super_Spiffy_Event_Calendar::get_events() );
switch_to_blog( $original_blog_id );
Super_Spiffy_Event_Calendar::render_plugins( $events );

A couple things we’d need to add in that aren’t noted here:

  • Caching. Shove it in a transient, so we’re not doing an expensive operation with blog switching on every page load.
  • Sorting. After building the aggregate, it’s probably worth sorting the events chronologically.
  • Display. I’d like to use or something similar to handle the output.

One thought on “Events Custom Post Type Proposal for Multisite

  1. Handling events (and event dates) is a requirement I meet again and again when developing custom WP sites. So I made my own very simple plugin:

    I stores the event date as a “2013-09-04” type of string in a regular custom field. Using meta_query, it’s easy to retrieve specific time ranges of posts, and sort them chronologically.

    Some advantages of that method:
    – You can enter fuzzy dates (people don’t necessary know the time, day or month of a far-future event).
    – You can freely manipulate the display format using php.
    – Being just a custom field, event dates can be added to any content type.

Comments are closed.