WordPress.org

Ready to get started?Download WordPress

Forums

Simple Events Calendar
[resolved] Sort Order & Pagination (3 posts)

  1. tombyrnes
    Member
    Posted 1 year ago #

    Hi

    I've really only started playing with this plugin. It seems very close to what I need. 2 questions:
    1. (And there have been 2 posts on this earlier - one was misunderstood). Is it possible to display events in DESCENDING order of event date ie newest first ... oldest?

    2. It does not appear to do the next/previous buttons after the specified number of posts have been displayed. (eg I've set 10 posts per page in Settings - Reading. Created 12 events and they all display on the one page.

    Thanks.

    Tom

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

  2. Jerry G. Rietveld
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Tom,

    All really good suggestions. I'll see if I can implement them in a future release.

    Thanks,
    Jerry

  3. slyphidine
    Member
    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic