Skip Navigation

[Resuelto] sort about datefield in rpg that comes from view

This support ticket is created hace 3 años, 5 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 5 respuestas, tiene 2 mensajes.

Última actualización por Luo Yang hace 3 años, 5 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#2057367

Hi,

i dont know if i asked it like this:

it is possible to sort parent view about datefield in rpg that comes from view?

i created a slider with some Dates as repeatableGroup fields with date in it. Now i would have the order about the next date.

thx for helping

best regards - alex

#2057391

Hello,

Toolset repeatable field group is based on one-to-many relationship, so each item of repeatable field group is also a post, the post type slug is same as repeatable field group slug.

And Toolset Views/Blocks plugin is using WordPress class WP_Query to query posts, you can order the result by custom fields of current post type, you can not order the result by another post type's fields:
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
‘meta_value‘ – Note that a ‘meta_key=keyname‘ must also be present in the query

So it is not possible with Toolset plugins, you might consider to move the custom date field from repeatable field group into the post

#2058589

hi, thx for the answer. But is it possible to copy a field from rpf to an field in parent when i save it? Then i can sort it.. - Or a workaround for this?

best regards - alex

#2059179

Unfortunately, there isn't such kind of built-in feature within Toolset plugins, one post can have multiple instance items in repeatable field group, so it won't be easy to move an RFG field into parent post, you might need to move it manually.

#2059353

hey - yes i recognize that toolset dont have a build-in-feature for that. But iam searching for a method to do this. If i find a snippet like something to update the Parent post on save - perhaps this way is good: https://developer.wordpress.org/reference/hooks/save_post/

You dont know a snippet for something?

best regards - alex

#2059433

Yes, it is possible with custom codes, for example, when you save a RFG item, use action hook save_post to trigger a PHP function:
https://developer.wordpress.org/reference/hooks/save_post/
In this PHP function, get the RFG item custom date field value:
https://developer.wordpress.org/reference/functions/get_post_meta/
Get the related(parent) post's ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
Update the related(parent) post's field value to what you want:
https://developer.wordpress.org/reference/functions/update_post_meta/