■現状
仕様かバグかはわかりませんが、WP3辺りのソースでは
・orderby は半角スペース区切りで複数指定可能
・order は DESC か ASC 1つのみ指定可能
で orderby で指定した最後のフィールドのみに order が適用されます。
今回の場合なら
ORDER BY meta_value_num, date DESC
となります(イメージ)ので
promotion_level 昇順 --> date 降順
でソートされます。
■対処
functions.php に以下を追加します。
add_filter('posts_orderby','my_posts_orderby', 10, 2);
function my_posts_orderby( $orderby, $query ) {
$orders = explode( ' ', strtoupper( $query->get( 'myorder' ) ) );
if ( 0 < count( $orders ) ) {
$orderby_array = array();
foreach ( explode( ',', str_replace( ' DESC', '', $orderby ) ) as $i => $the_orderby ) {
if ( ! isset( $orders[$i] ) || ! in_array( $orders[$i], array( 'ASC', 'DESC') ) )
$orderby_array[] = $the_orderby . ' DESC' ;
else
$orderby_array[] = $the_orderby . ' ' . $orders[$i];
}
$orderby = implode( ',', $orderby_array );
}
return $orderby;
}
query_posts で order の指定を myorder に変更します。
$args = array(
'meta_key' => 'promotion_level',
'orderby' => 'meta_value_num date',
'myorder' => 'DESC DESC'
);
query_posts( $args );
で OK!