Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

slyphidine on "[Plugin: Simple Events Calendar] Changing event sort order"

$
0
0

I saw a few questions about this. I answered it on the original question, but thought it might be hard to find. So here it is:

I was able to change the sort order by adding some code to the php file. Within the simple-events-calendar.php file find the following block:

function eventquery($label,$age,$range,$limit) {
	global $wpdb;
	$table_name = $wpdb->prefix . "simple_events";
	if(!is_null($age) && !is_null($label)) {
		$conditions = "WHERE event_label = '$label' AND $range ORDER BY event_start $limit ";
	} elseif(!is_null($age)) {
		$conditions = "WHERE $range ORDER BY event_start $limit";
	} elseif(!is_null($label)) {
		$currentTime = time();
		$conditions = "WHERE event_label = '$label' AND event_end >= $currentTime ORDER BY event_start $limit ";
	} else {
		$currentTime = time();
		$conditions = "WHERE event_end >= $currentTime ORDER BY event_start $limit ";
	}

In the four places after the $limit" part, add DESC. So the first instance would change from:

$conditions = "WHERE event_label = '$label' AND $range ORDER BY event_start $limit ";

to

$conditions = "WHERE event_label = '$label' AND $range ORDER BY event_start $limit DESC";

The 4 separate lines are for when there are limiters placed in the events tag (such as [events age=expired]. With this, I was able to just place it on the limiter for age. That made my upcoming events in ascending date order, and my past events (the ones that used the age limiter) in descending order.

Hope that helps!

http://wordpress.org/plugins/simple-events-calendar/


Viewing all articles
Browse latest Browse all 8245

Trending Articles