ACF sorty by relationship field

Forums › Forums › Search & Filter Pro › ACF sorty by relationship field

Viewing 2 posts – 1 through 2 (of 2 total)
  • Anonymous
    #227324

    Hi, I want to sort my posts by a relationship field in alphabetical order.
    But Instead of using the title it’s using the Custom Post Type IDs.
    Is there a way to tell the system it’s supposed to take the term and not the id?

    Trevor
    #227327

    Not easily, sorry, no (if at all). The problem is that we index the cache by that ID, because, in the posts being searched, that is all ACF stores in the custom field. For the form, we have to use some code to grab the label.

    What you would have to do is set no sort in the form settings, but instead use this filter:

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

    In that, you would need to somehow (I don’t know how) need to create an array with the post IDs of the related post type and their labels, and some how set up an orderby that would do what you want. As I said, I cannot think how that could be done.

Viewing 2 posts – 1 through 2 (of 2 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.