WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
How to sort the event list. (2 posts)

  1. kimipooh
    Member
    Posted 11 months ago #

    According to http://tri.be/support/documentation/the-events-calendar-template-tags-general-functions/#functiontribe_get_events, the event values getting by tribe_get_events() are sorted by event date (order) ascending.
    I would like to change the sort type (descending), but I understand that tribe_get_events() cannot support the "orderby". Is it right?

    In other words, the following "DESC" value is ignored.

    $events = tribe_get_events( array( 'eventDisplay'=>'all', 'posts_per_page'=>5, 'order' => DESC ) );

    I have used the following other way, but I hope to expand the function.

    * WP_Post was supported by WordPress 3.5 or above version.

    $events = tribe_get_events( array( 'eventDisplay'=>'all', 'posts_per_page'=>5);
    $s_date = array();
    foreach ($events as $v){
      $vc = new WP_Post($v);
      $vv = $vc->to_array();
      $s_date[] = $vv['EventStartDate'];
    }
    array_multisort($s_date, SORT_DESC, $events);

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

  2. jonahcoyote
    Member
    Posted 11 months ago #

    Hi kimipooh,

    That is correct, tribe_get_events() will ignore ordering and use it's own based on the 'eventDisplay' arg. If you want to use your own ordering you could also use WP_Query: https://gist.github.com/jo-snips/5112025

    I hope that helps but let me know if you have any other questions.

    - Jonah

Reply

You must log in to post.

About this Plugin

About this Topic