I have a post type and I want to sort posts in its archive according to two values:
- by a meta value called "artwork_year" which contains a 4 digit number (year)
- by post publish date
what the query should do is: first get the artwork_year and sort the posts accordingly (show first higher number... ie first 2012 artwork, then 2011, then 2010, etc), then since many posts share the same year, sort them by publish date.
I followed instructions at http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters then tried with
$artwork = array(
'post_type' => 'artwork',
'posts_per_page' => 10,
'paged' => get_query_var( 'paged' ),
'meta_key' => 'artwork_year',
'orderby' => 'meta_value_num date',
'order' => 'DESC'
);
query_posts( $artwork );
while ( have_posts() ) : the_post();
// loop stuff
endwhile;
wp_pagenavi();
however, if I do this... the order is not right... now I set it to DESC which is the default; it should display first artwork from 2012, then 2011... and sort the artwork with the meta value 2011 or 2012 according to pub date... however what I get is first 2011 artwork in any case (regardless of if order is set to ASC or DESC) then 2012 posts... how do I get 2012 first and then 2011 and all others?
thank you!