• Resolved peter8nss

    (@peter8nss)


    The ORM order_by for start_date does not appear to be working. My code has the following:

    $events = tribe_events()->where( 'starts_on_or_after', '2024-09-01' )->order_by( 'start_date', 'ASC' )->get_ids();

    The ids returned are in ascending id order, not ascending start date order.

    Replacing the code by:

    $events = tribe_events()->where( 'starts_on_or_after', '2024-09-01' )->order_by( 'meta_value', 'ASC' )->get_ids();

    Does get the correct order – presumably because the start_date query is really a meta data query on _EventStartDateUTC and in WP_Query you can specify ordering on that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Andras Guseo

    (@aguseo)

    Hi @peter8nss

    Thanks for reaching out!

    start_date is not a valid parameter. You could use the following instead:
    * event_date
    * _EventStartDate or _EventStartDateUTC – yeah, basically the meta key.
    * _EventEndDate or _EventEndDateUTC

    Full example:
    $events = tribe_events()->where( 'starts_on_or_after', '2024-09-01' )->order_by( 'event_date', 'ASC' )->get_ids();

    Hope this helps.

    Cheers,
    Andras

    Thread Starter peter8nss

    (@peter8nss)

    You might want to get the published ORM documentation updated to reflect that, as the example for “order_by” is:

    $events = tribe_events()
    ->order_by( 'start_date', 'DESC' )
    ->all();
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.