• I have an ACF custom field called Ranking. That has custom posts ranked from 1 through 14.

    I’m using the Dynamic OrderBy Field to order these posts by ranking in a Loop grid.

    For some reason it’s ranking posts like this:

    1,10,12,13,14,2,3,4,5,6

    How can I ensure it ranks posts 1,2,3,4….10,11,12?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter jakehower

    (@jakehower)

    ChatGPT is telling me:

    The issue you’re encountering is due to the fact that your custom field values are being treated as strings rather than integers. When treated as strings, the ’10’ comes before ‘2’ because ‘1’ is less than ‘2’.

    For now I’ve added 0 before the lower numbers and it seems to be sorting correctly.

    Maybe a consideration to add a sort via integer if the field is as such?

    Plugin Author Shabti Kaplan

    (@shabti)

    Good job finding the answer to this issue. I will check to see if this is indeed the case and I will let you

    I got pretty much the same behavior. I have plenty of article with thousands view but these was the 9 selected by the plugin:

    998,984,982,979,964,962,956,95,911

    I guess that the issue is on the formatting of the values. The article with 3 / 4 view has been ignored and there is the 95 in the list.

    • This reply was modified 1 year, 6 months ago by fyase.
    • This reply was modified 1 year, 6 months ago by fyase.

    Likewise, I’m trying to sort a sports player page by player number but it is sorting by string rather than integer.
    Update us if there are any fixes!

    Hello everyone,
    Did you find any way to overcome this issue?
    I have similar problem using it with WP-PostViews. In my case it only takes into account posts that have 9 or less views and list them but doesn’t take into account posts with higher view value..

    You need to change the plugin code in module.php on line 555 from
    $query_vars[ ‘orderby’ ] = ‘meta_value’;
    to
    $query_vars[ ‘orderby’ ] = ‘meta_value_num’;

    This will be replaced if you update the plugin so make sure to do it correctly

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dynamic OrderBy Field ordering incorrectly’ is closed to new replies.