WP_Query

WP_Query class parameters available for Events Maker.

Description

Retrieves a list of events matching the given criteria. May be used instead of em_get_events() or get_posts() function (with specific parameters).

Usage

Standard events loop.

// Default $args
$args = array(
	'post_type' => 'event', // required
	'suppress_filters' => FALSE, // required
	'posts_per_page' => -1 // optional
);

// The Query
$events = new WP_Query($args);

// The Loop
if ($events->have_posts()) {
	while ( $events->have_posts() ) {
		$events->the_post();
		echo '<li>' . get_the_title() . '</li>';
	}
} else {
	// no events found
}
// Restore original Post Data
wp_reset_postdata();

Parameters

All the parameters can be used in WP_Query, em_get_events() and get_posts() functions.

  • $args | array – an array of parameters that can be used for events query
    • event_start_after | string – events that start after the given date (if event_date_range => ‘between’). Defaults to ”
    • event_start_before | string – events that start before the given date (if event_date_range => ‘between’). Defaults to ”
    • event_end_after | string – events that end after the given date (if event_date_range => ‘between’). Defaults to ”
    • event_end_before | string – events that end before the given date (if event_date_range => ‘between’). Defaults to ”
    • event_date_range | string – events range. Defaults to ‘between’
      • between – include all the events in between the given range, that start after event_start_after and event_start_before, and at the same time end after event_end_after and event_end_before,
      • outside – include all the events outside of the given range, that start after event_start_after and event_start_before, and at the same time end after event_end_after and event_end_before,
    • event_date_type | string – type of events. Defaults to ‘all’. Available parameters:
      • all – include all event types
      • all_day – include only all day events
      • not_all_day – exclude all day events
    • event_ticket_type | string – type of tickets used for events. Defaults to ‘all’. Available parameters:
      • all – include all event types
      • free – include only free events
      • paid – include only paid events
    • event_ondate | string – include events for a given date. Defaults to ”. Available parameters:
      • YYYY – include events form a given year, for example: 2013
      • YYYY/MM – include events form a given year and month, for example: 2013/09
      • YYYY/MM/DD – include events form a given year, month and day, for example: 2013/09/15
    • event_show_past_events | boolean – weather to include past events in the results or not. Defaults to event_show_past_events option in plugin settings.

Date formats available for event_start_after, event_start_before, event_end_after and event_end_before parameters: Y-m-d (2013-09-16), Y-m-d H:i (2013-09-16 18:58) or Y-m-d H:i:s (2013-09-16 18:58:44).

Return

Identical to get_posts() – a list of event (post) objects.

Leave a Reply

Your email address will not be published. Required fields are marked *

4 comments on "WP_Query"

  1. There is a bug on the current latest version 1.6.11 which does not clean transients for full-calendar display. This bug then prevents displaying any type of update made to the events on the calendar view on front-end. Once the calendar view is loaded it can never ever be changed, we’re stuck with those events. How can this be fixed?

    • Solved in 1.6.12

  2. what is meaning of ( suppress_filters’ => FALSE )

    • the suppress filter Wp_Query parameter set to false enables query adjustments via filter hooks. when you set it to true is like saying: don’t apply any query filters.

      EM uses filter hooks to extend default query with recurring events, date comaprison etc.