Order events by End Date

Home Forums Calendar Products Events Calendar PRO Order events by End Date

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #956603
    Neasa Ronayne
    Participant

    Hi I am looking to order by events by end-date. I have read a number of posts that reference tribe_events_query_posts_orderby, but I can’t find this in the technical documentation to see the structure of this hook.
    I have also read up on using the wp pre_get_posts. This is what I have implemented:

    function event_title_sort($query) {
    	if ( !is_admin() && ( $query->tribe_is_event || $query->tribe_is_event_category ) ) {
    		$query->set( 'meta_key','EventEndDate' );
    		$query->set( 'orderby','meta_value_num' );
    	}
    }
    add_action( 'pre_get_posts', 'event_title_sort', 100, 1 );

    This seems to order the posts by end date but it seems to be ordering it by meta_value (1,12,2,3,34,9) rather than meta_value_num (1,2,3,9,12,34), it also changes the start date to match the end date (this change is only to the text appearing not the actual event start date)

    Any suggestions or solutions would be much appreciated.
    Thanks.

    #956734
    Brian
    Member

    Hi,

    Thanks for using our plugin.

    The plugin is designed to order events by the start date and time so changing this could be tricky and create unintended issues.

    However, we use a couple different ones for order:

    meta_value
    meta_key

    Do either of those work?

    #956958
    Neasa Ronayne
    Participant

    Hi Brian,

    Thanks for the quick response. No worries I understand any help would be much appreciated.

    As I previously stated I have used both those. They seemed to order the events 1,12,3,9 rather than 1,3,9,12. So I tried meta_value_num to solve this issue but it remains the same.
    As a test I tried these to order the events by title and it worked fine, the issue seems to be that I am dealing with numbers.

    Cheers

    #956977
    Brian
    Member

    Ok thanks for the information. Glad you are able to move forward on your customization.

    Since there is nothing more we can do here on a customization I am closing out this ticket, but if you have any other issues related to this or something new, please create a new one.

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Order events by End Date’ is closed to new replies.