i'm using this query
$numposts = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=5&showposts='.$numposts.'&paged=' . $paged);
how to order the posts by custom field?
how about?
$customfield = "MyCustomFieldName";
$numposts = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=5&showposts='.$numposts.'&paged='.$paged.'&meta_key='.$customfield.'&
orderby=meta_value&order=DESC');
or instead of creating a new variable just to hold the custom field just add it straight into the query..
query_posts('cat=5&showposts='.$numposts.'&paged='.$paged.'&meta_key=mycustomfield&
orderby=meta_value&order=DESC')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With