Skip Navigation

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

This support ticket is created hace 1 año, 8 meses. There's a good chance that you are reading advice that it now obsolete.

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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por diyanK hace 1 año, 8 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#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.