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.