Hi
I have been trying to order posts from one category in desc or asc order depending on a numerical value in a custom field.
I believe that wordpress 3.0 have orderby=meta_value_num implemented which should order post using the values in a custom field by-passing previous problems due to sql considering custom field values as strings and not integers.
This is the query I am using:
query_posts("cat=$current_id&meta_key=rated&orderby=meta_value_num&order=DESC");
But I do not get the posts ordered as supposed when using this query.
Any help?
Try:
query_posts("cat=" . $current_id . "&meta_key=rated&orderby=meta_value_num&order=DESC");
Hello
$sel = array(
"post_type"=>"page",
"posts_per_page"=>2,
"meta_key"=>"position",
"post_status"=>"publish",
"orderby"=>"meta_value_num",
"order"=>"ASC",
);
query_posts($sel);
not orderBy position number(((
why?
'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'.
http://codex.wordpress.org/Function_Reference/WP_Query#Order_.26_Orderby_Parameters
I read this, but I present in my query "meta_key"=>"position", but it doesn't work.