I am ordering my posts by using a custom field "order".
For each post the value of order is a number, which dictates where I want the post to be positioned.
I have the following:
This seems to have worked fine up until post #10, this posts positions itself at 2nd in the list.
Any ideas as to where I am going wrong?
Funny Character Appearing in my WordPress Pages Content
1:when do i use wordpress [closed]
to (values will be treated as number). Wordpress working locally then uploading
When sorting by number, use meta_value_num instead of meta_value to make WordPress tret the value as a number instead of string.. WordPress Post Thumbnail I had the same problem, Sheikh Heera helped me out and it works like a charm.. Restrict access to WordPress site
$querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'your-custom-field-name' AND wposts.post_type = 'post' ORDER BY CAST(wpostmeta.meta_value AS DECIMAL) DESC ";