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.
Leave a Reply
You must be logged in to post a comment.
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.
You must be logged in to post a comment.
You can use the plug-in provided function
eo_get_events()
. This is essentially a wrapper forget_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 )assuming mountain-bike is the slug of your category term
The only plug-in specific arguments here are
event_start_after
andevent_start_before
which accept a date string in ‘YYYY-MM-DD’ format (as above, or a relative date such as+1 week
orthird Thursday of this month
– please note available relative dates will depend on your php version).There are also
event_end_after
andevent_end_before
arguments available. All of these can be used in aWP_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).