• Resolved TrekRight

    (@trekright)


    REPRODUCE:
    1. Set up a Number-type field in ACF labelled Sort Weight (or any other name that you wish). In my case, the field name is ‘sort_weight’.
    2. Create three posts titled ‘A’, ’B’, and ‘C’. In them, assign the values of 2, 100, and 1 respectively to the Sort Weight field.
    3. In another post, add an Advanced Query Listing Builder.
    4. Configure the Builder as follows: under the Data Settings, set the Order to ‘Meta key’, Sorting to ‘Ascending’, and then Meta key to ‘sort_weight’.
    5. Save the post and display in the front end.

    EXPECTED:
    C
    A
    B

    That is, I expected the posts to be sorted in ascending numerical order based on the ‘sort_weight’ field (C=1, A=2, B=100).

    ACTUAL:
    C
    B
    A

    It appears the sort was done based on the *text value* of the sort field, even though the sort field’s type in ACF was ‘Number’.

    It would be very, very handy to be able to sort based on the field type rather than the textual representation of that type.

Viewing 1 replies (of 1 total)
  • Thread Starter TrekRight

    (@trekright)

    Sorry – disregard. I only just realized that there is a separate ‘Meta key’ for ‘Meta key as number’. I did not see that optional originally.k

Viewing 1 replies (of 1 total)

The topic ‘Incorrect Sort Order Using Advanced Query Listing Builder’ is closed to new replies.