Sort posts in ACF relationship field

Would it be possible to sort an acf_relationship loop? This isn’t working for me:

<Loop acf_relationship=field_name sort_field="title">
  <Field title />
</Loop>

I’ve also tried:

<Loop acf_relationship=field_name orderby=id order=desc>

And:

<Loop acf_relationship=field_name orderby_field=test order=desc>

Nothing seems to change the order of a relationship loop.

Hi Richard,

In the newest plugin version, it now supports sorting posts in an ACF relationship field.

You can use orderby or orderby_field, described in the query parameters for the post loop. That’s the fastest method to order by raw field value.

For field types that are more than simple text value, you can try sort_field, documented in the page titled Loop query. This is slower, because it sorts the result after the database query - but it supports a wider range of values, such as dates and other ACF field types.

1 Like

That works perfectly. Thanks so much!

L&L really takes the work out of complex data structures.