Skip Navigation

[Gelöst] sort about datefield in rpg that comes from view

This support ticket is created vor 3 Jahren, 6 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 3 Jahren, 6 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#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/