Years ago, I built a function that would pull posts from The Event Calendar events for a specific day and display them as a grid, with venue on one axis and time on the other. To do this, I need the query to sort the results by venue, then time.
When I revisited the function today, I found it was no longer sorting properly. I can sort by title just fine or by the datetime field from The Event Calendar fine, but it will no longer sort by venues, which are stored in a Toolset custom field.
The query arguments are:
$secondargs = array(
'post_type' => 'tribe_events',
'post_status' => 'publish',
'posts_per_page' => '-1',
'eventDisplay' => 'custom', // this just makes The Events Calendar display all posts
'meta_query' => array(
'relation' => 'AND',
array( // Only get posts with this date
'key' => '_EventStartDate',
'value' => $dateToShow,
'compare' => 'LIKE',
'type' => 'DATE',
)
),
'meta_key' => 'wpcf-event-venue-specificname',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_type' => 'CHAR',
);
Instead, it seems it is sorting by title. As I said, this function worked properly for years, so I don't know what could be causing the issue. Here is the page with one of the days' data displayed without styling: hidden link
Hello. Thank you for contacting the Toolset support.
Can you please share admin access details and also tell me where you added the function code you shared.
Also, please share what is your expected result with the problem URL you shared.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I checked the query and I see you are using the custom shortcode with custom query.
I checked and with updates of the The Events calendar plugin it seems its changed.
Can you please get in touch with the The Events Calendar plugin support and check with them if they offer any hook that will help to change the orderby clause using custom field created using Toolset Types plugin.
I have submitted a support ticket with The Events Calendar and will report back on what they say. I would have thought that by doing a direct query of these posts, that The Events Calendar code would not interfere, but maybe I'm wrong in that assumption.
So far, all The Events Calendar people have given me is this parameter:
'tribe_suppress_query_filters' => true,
It hasn't done anything to fix this problem of only allowing sorting by title or date/time fields, but I wanted to share it here in case it is of use to somebody else.