Eventlist shortcode doesn't work with recurring events solution
-
When using the eventlist shortcode in combination with recurring events, the eventlist doesn’t show the correct items. Reason is the LIMIT part in the SQL statement in combination with the ORDER BY START part.
When you have yearly recurring events like birthdays like for examplee this:
5-1-1944
10-1-1945
20-1-1933and you set to limit the items in the eventlist to two, the sql statement returns the events 20-1-1933 and 5-1-1944 (today is 7-1-2015). That is incorrect.
I replaced the db_query_events function in ajax-event-calendar.php with the folowwing to fix this:
function db_query_events($start, $end, $category_id, $excluded, $limit=false) { global $wpdb; $excluded = ($excluded) ? 'NOT IN' : 'IN'; $andcategory = ($category_id) ? " AND category_id {$excluded}({$category_id})" : ''; $limit = ($limit) ? " LIMIT {$limit}" : ""; // RC20150106 --> $orderby = "concat(IF(repeat_freq > 0, IF(MONTH(start) < MONTH(curdate()), YEAR(curdate())+1, YEAR(curdate())), YEAR(start)), LPAD(MONTH(start), 2, '00'),LPAD(DAY(start), 2, '00'))"; /*$result = $wpdb->get_results("SELECT id, user_id, title, start, end, allDay, repeat_int, repeat_freq, repeat_end, category_id FROM " . $wpdb->prefix . AEC_EVENT_TABLE . " WHERE ( (start >= '{$start}' AND start < '{$end}') OR (end >= '{$start}' AND end < '{$end}') OR (start <= '{$start}' AND end >= '{$end}') OR (start < '{$end}' AND (repeat_freq > 0 AND repeat_end >= '{$start}')) ) {$andcategory} ORDER BY start{$limit};");*/ $result = $wpdb->get_results("SELECT id, user_id, title, start, end, allDay, repeat_int, repeat_freq, repeat_end, category_id FROM " . $wpdb->prefix . AEC_EVENT_TABLE . " WHERE ( (start >= '{$start}' AND start < '{$end}') OR (end >= '{$start}' AND end < '{$end}') OR (start <= '{$start}' AND end >= '{$end}') OR (start < '{$end}' AND (repeat_freq > 0 AND repeat_end >= '{$start}')) ) {$andcategory} ORDER BY {$orderby};"); //<-- return $this->return_result($result); }Parsing recurring events and sorting them still happens in the render_eventlist_events method, so you probably don’t even have to change the ordering of the query.
Please verify this fix and add it to the plugin.
Regards,
Rob
The topic ‘Eventlist shortcode doesn't work with recurring events solution’ is closed to new replies.