Leave a Reply

1 comment

  1. From the codex at WP_Query’s page:

    ‘meta_value’ – Note that a ‘meta_key=keyname’ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect). Use ‘meta_value_num’ instead for numeric values.
    ‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’.

     $my_query = new WP_Query( array( 
                            // 'post_type' => 'post_type_name',
                            'meta_key' => 'key_name',
                            'orderby' => 'meta_value_num'
                            )); 
    

    You can check out the Orderby Parameters on that same link.