• Resolved George

    (@quantum_leap)


    I am trying to sort posts that have a numerical custom field value in descending order (posts with a larger number to appear first). I have this shortcode:

    [wp_show_posts id="170" settings="meta_key=my_custom_field&orderby=meta_value&order=DESC"]

    But id doesn’t seem to order them accordingly, it seems kind of random. Am I missing something?

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

    (@quantum_leap)

    After further research, I discovered that sorting numerical values needs the use of meta_value_num parameter.

    [wp_show_posts id="170" settings="meta_key=my_custom_field&orderby=meta_value_num&order=DESC"]

Viewing 1 replies (of 1 total)

The topic ‘Sort posts by numerical custom field’ is closed to new replies.