Wordpress meta_query过滤类型数字不起作用

时间:2017-04-02 10:12:07

标签: wordpress

我有一个这样的meta_query:

$meta_query_args = array(
    'relation' => 'AND',
    array(
        'key'     => 'apartment-price',
        'value'   => array(50000, 100000),
        'compare' => 'BETWEEN',
        'type' => 'numeric'
    ),
    array(
        'key'     => 'apartment-block',
        'value'   => $data['block'],
        'compare' => 'IN'
    ),
    array(
        'key'     => 'apartment-floor',
        'value'   => intval($data['floor']),
        'compare' => 'IN',
        'type' => 'numeric'
    )
);

$meta_query = new WP_Query( 
                    array( 
                        'post_type' => 'apartment',
                        'meta_query' => $meta_query_args
                         ) 
                    );

我想过滤50000到100000之间的公寓价格,但我得到这样的查询:

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )  INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id )  INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) WHERE 1=1  AND ( 
  ( wp_postmeta.meta_key = 'apartment-price' AND CAST(wp_postmeta.meta_value AS SIGNED) BETWEEN '50000' AND '100000' ) 
  AND 
  ( mt1.meta_key = 'apartment-block' AND mt1.meta_value IN ('B') ) 
  AND 
  ( mt2.meta_key = 'apartment-floor' AND CAST(mt2.meta_value AS SIGNED) IN ('1') )
) AND wp_posts.post_type = 'apartment' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10

所以它不起作用,因为这些数字已被引用。为什么参数'键入'不管用?请帮忙! BTW公寓楼过滤器也不行,原因相同。

0 个答案:

没有答案