I've a custom post type that has a custom filed called deck-number and client wants to sort the result by deck number. FYI, deck numbers are numeric values. So I used query like bellow.


The issue I'm facing is I'm getting result sorting like 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9.

I need your advice to solve.


1 Answer 1


Use meta_value_num with orderby instead of meta_value.

meta_value is used to order alphabetically. meta_value_num used to order numerically.

For more information, check this: Codex get_posts And this for detailed information: Codex WP_Query

  • You saved my day :)
    – IFightCode
    Dec 5, 2013 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.