Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Show us what you have tried already and where exactly you got stuck. –  toscho May 2 '12 at 8:06
add comment

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
That's great - thank you very much –  Brad May 2 '12 at 13:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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