Skip Navigation

[Resolved] Sorting a classic view table layout using a child post's Date custom field value

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by diyanK 1 year, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#2570391

Hi Team,

I have a Classic View that displays a CPT in a table style.
One of the table columns includes a value that comes from a related (child) post's custom field(date type).

Is it possible to sort the table rows (like we usually do by clicking on the table heading) by taking the child post's custom field value in mind?

Currently the sorting is just able to differentiate between posts that have that child post's field filled in, and those that are empty.
However I'd like to get that going properly. I tried different date formats and even "raw" (the unix timestamp), however the sorting doesn't seem to have an idea of the actual values.

Best,
D.

#2571809

Hello,

Toolset Views/Blocks plugins are using WordPress built-in class WP_Query to query posts, so you can sort the result by post fields you are querying(Parent post type), can not sort result by fields of other post type(child post type)

More helps:
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
‘meta_value_num‘ – Order by numeric meta value (available since version 2.8). Also note that a ‘meta_key=keyname‘ must also be present in the query.

#2572395

Hi Luo,

I have managed to solve the issue myself. I have changed my view to query the child post instead, and sort the table based on it's custom field. Then I have queried the rest of the fields that I require by pulling them from the parent post fields.

Thanks anyway!

D.