How to list events by category and month with plugin Event Organiser?

You can use the plug-in provided function eo_get_events(). This is essentially a wrapper for get_posts(), and so is intended for ‘secondary’ loops.

The plug-in specific arguments can also be given to a WP_Query object – in case you wanted to modify the main loop. (Related: When to use WP_query(), query_posts() and pre_get_posts )

$events = eo_get_events(array(
   'tax_query'=>array(
      array(
        'taxonomy' => 'event-category',
        'field' => 'slug',
        'terms' => 'mountain-bike'
      )
    )
   'event_start_after'=>'2012-07-01',
   'event_start_before'=>'2012-07-30',
  ))

assuming mountain-bike is the slug of your category term

The only plug-in specific arguments here are event_start_after and event_start_before which accept a date string in ‘YYYY-MM-DD’ format (as above, or a relative date such as +1 week or third Thursday of this month – please note available relative dates will depend on your php version).

There are also event_end_after and event_end_before arguments available. All of these can be used in a WP_Query object too.

Please note eo_get_events() sets some defaults (See documentation).

Return is an array of post objects (of ‘event’ post type). This answer shows how to display the returned posts (see get_posts() section).

Leave a Comment