Quantcast
Channel: Question and Answer » meta-query
Viewing all articles
Browse latest Browse all 36

Orderby doesn't work like expected on custom query

$
0
0

I have this custom query:

query_posts(  
  array ( 
    'orderby' => 'rr_recommends_count',
    'meta_key' => 'rr_recommends_count',
    'order' => 'DESC',
  )
);

Which orders the posts like this:

9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 1 etc.

I see that the problem is that the meta_value field has a type of longtext.

How can I fix the sort without changing the meta_value field type?


Viewing all articles
Browse latest Browse all 36

Trending Articles