I have a custom coded form on the page to search for events, entering a keyword and/or start/end dates. With the form’s values, I’m querying the events as follows:
if ($date_from = $_GET['date_von']) {
$cd = explode('-',$date_from);
if (!checkdate((int)$cd[1], (int)$cd[2], (int)$cd[0]))
$date_from = "";
}
if ($date_to = $_GET['date_bis']) {
$cd = explode('-',$date_to);
if (!checkdate((int)$cd[1], (int)$cd[2], (int)$cd[0]))
$date_to = "";
}
$args['limit'] = 10;
$args['search'] = urldecode($_GET['s']);
$events_count = EM_Events::count($args);
$args['offset'] = (isset($_REQUEST['pno'])) ? $args['limit'] * $_REQUEST['pno'] : 0;
$args['page'] = (isset($_REQUEST['pno'])) ? $_REQUEST['pno'] : 1;
if ($date_from)
if($date_to) {
if($date_from > $date_to) {
$t = $date_from;
$date_from = $date_to;
$date_to = $t;
}
$args['scope'] = $date_from.','.$date_to;
} else
$args['scope'] = $date_from.',9999-01-01';
elseif($date_to)
$args['scope'] = date('Y-m-d').','.$date_to;
foreach (EM_Events::get($args) as $EM_Event): $WP_Event = get_post($EM_Event->post_id);
//display event