3

I need to display a list of events by category and month. For example I need to list all the Mountain Bike events in July.

1
  • Show us what you have tried already and where exactly you got stuck.
    – fuxia
    May 2, 2012 at 8:06

1 Answer 1

2

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).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.