Wordpress 自定义字段顺序

Wordpress custom field order by

我正在尝试通过自定义字段订购 InPrice 但无法做到这一点。我想知道是否可以通过其他方式实现 ('orderby' => 'meta_value_num', 'order' => 'ASC',)

$args = array(
    'post_type' => 'post',
    'posts_per_page'=>-1,
    'meta_key' => 'InPrice',
    'meta_value'   =>  array( $pieces[0], $pieces[1]),
    'meta_type'    => 'numeric',
    'meta_compare' => 'BETWEEN',
    'orderby' => 'meta_value_num',
    'order' => 'ASC',
    'meta_query'   => array(
        'relation' => 'AND',
            array(
                'btown' => array(    
                    'key'     => 'Town', 
                    'value'   => $town,
                    'type'     => 'STRING',
                    'compare' => 'LIKE', 
                ),
                broom' => array(
                    'key'     => 'Rooms', 
                    'value'   => $rooms,
                    'compare' => 'LIKE', 
                ),                                                                      
            ), 
       ),               
);

参考Wordpress Documentation 您可以使用类似下面的代码:

$args = array(
    'post_type'  => 'post',
    'posts_per_page'=>-1,
    'order'      => 'ASC',
    'meta_query' => array(
        array(
            'key'     => 'age',
            'value'   => array( array( $pieces[0], $pieces[1]) ),
            'compare' => 'IN',
        ), // other meta queries that you want 
    //don't forget to set a relation type for them in here ex:'relation'=>'AND',
    ),
);
$query = new WP_Query( $args );