[wp-hackers] get_posts() meta_key numeric search
Mike Little
wordpress at zed1.com
Fri Jun 8 11:59:09 UTC 2012
On Fri, Jun 8, 2012 at 12:46 PM, Christopher Ross <cross at thisismyurl.com>wrote:
> I'm calling a get_posts() function using the meta_key to sort but it's
> returning the 1's out of order at the moment. For example:
>
> $args = array(
> 'numberposts' => 30,
> 'meta_key' => 'image_score_' . $user_id,
> 'orderby' => 'meta_value',
> 'order' => 'DESC',
> );
>
> Will return 99,98,9,100,10,1 instead of 100,99,98,10,9,1
>
>
Use
'orderby' => 'meta_value_num'
To force a numerical comparison (default is string comparison).
Mike
--
Mike Little
http://zed1.com/
More information about the wp-hackers
mailing list