Sorting order in Wordpress with advance custom field

So I have a ACF called 'track_number' in order to sort each song (CPT) on the album pages (based on their taxonomy).

On the album page I run this loop to get the songs:
query_posts('showposts=20&post_type=song&album='.$post_slug.'&meta_key=track_number&orderby=meta_value&order=ASC');

And for the most part I get what I expected minus one problem, the double digit numbers are jumping ahead (1,10,11,2,3...).

I tried to just put '0' in front of all the single digit fields but it didn't work. Ultimately I'd like to resolve it as is anyways. Any ideas?

    Kimberly

    Hopefully one of our more experienced coding members will have some advice :)

    Mason

    Hiya, try using meta_value_num as the orderby parameter. Thx.

    Div Truth
    • Elite
    • 62
    • #1,906

    Genius Mason, per genius, thanks so much that was so simply (facepalm)

    Mason

    I get an occasional one or two right :) Glad we were able to help

Join 372738 happy members

Get access to our entire collection of epic plugins, astonishing themes & genius support

Become a member