Skip Navigation

[Waiting for user confirmation] query sortby custom field no longer working

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 replies, has 1 voice.

Last updated by Minesh 11 hours, 5 minutes ago.

Assisted by: Minesh.

Author
Posts
#2826099

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

#2826134

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2826248

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2826264

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.

#2826431

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - please share details if they have any hook to override the orderby clause.

#2827015

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.

#2827134

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Are you checking with them still?

I see there is a hook "relevanssi_orderby":
- hidden link

you can check with them if that helps.