You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @eliot-akira can we have a custom order for ACF with multiple values such as acf_post, acf_relationship, acf_select, and other fields that often store values, and having the ability to order queries based on these arrays?
Hi @ghen-arvesu - Thank you for making a note of this. The feature description and example usage is a great reference for developing the feature, I appreciate it.
ACF field loops with multiple values are usually based on the List loop type, which supports sorting by field with:
I think the difference needs a better explanation in the docs, maybe the topic deserves its own page.
The query parameter orderby is supported by the post loop type, which passes it to WP_Query to make a database query. Similarly, the taxonomy loop type with WP_Term_Query and user loop with WP_User_Query. Each of these is a separate implemenation in WP core with some differences in accepted values.
The generic loop parameter sort_field is supported by the base loop, which all loop types are built on. Any loop type with multiple values, including the result of post queries, can be sorted as long as it's a list of objects with sortable field values (like number, string, date).
ACF Repeater probably can't be sorted this way, since it's a list of various field types.
..Looking at the code where the ACF Post loop is created (here), it gets the list of post IDs from ACF and creates a post loop, not a generic list. So the orderby query parameter is supposed to be working. I'll look into what's happening there.
Hi @eliot-akira can we have a custom order for ACF with multiple values such as acf_post, acf_relationship, acf_select, and other fields that often store values, and having the ability to order queries based on these arrays?
An example of maybe something like below:
Which could be based on the values below
this is related to a post on https://tangibletalk.com/t/acf-repeater-loop-filtering/1275
The text was updated successfully, but these errors were encountered: