I’m trying do order a custom post type page by 2 variables:
– first is the custom post type meta_key “date”
– then, for posts with the same date, it should be ordered by meta_key “number”
I’m willing to set for some kind of ordering on the second level but right now it really seems random:
<?php $my_query = new WP_Query( array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'options_type',
'value' => 'Denim'
),
),
'orderby' => 'meta_value',
'meta_key' => 'options_date',
'posts_per_page' => 50 ,
'order' => 'DESC'
)); ?>
Even editing the “wordpress publication date” doesn’t affect the “same day” order. So I end up with:
- 09.03.2012 244 Diesel (wordpress date 3.8.2012)
- 09.03.2012 246 Levi’s (wordpress date 3.9.2012)
- 09.03.2012 247 Evisu (wordpress date 3.10.2012)
(i’m using european date displayng, so 09.03 means March, 9th)
edit
just to clarify:
I’ve some custom field and i’ve set a specific options_date field for the custom post type, which is different from the wordpress date.
I would like to order the posts using a multiple order: custom field “options_date” and, inside the same “options_date” by another custom field “options_info”.
ordering with
'orderby' => 'meta_value date',
doesn’t seem to work and it’s not the target result, I’m looking for a multiple meta_key ordering.