简体   繁体   English

嵌套到嵌套元查询冻结在 WordPress

[英]Nested to nested meta query freezes in WordPress

I am trying nested query to nested query.. the problem is that when a have multiple query conditions the query freezes.. This is my code..我正在尝试嵌套查询到嵌套查询..问题是当有多个查询条件时查询冻结..这是我的代码..

array(
    'relation' => 'AND',
    array(
        'relation' => 'OR',
        array(
            array( 'key' => 'bedrooms', 'value' => intval($bedrooms), 'compare' => '=' )
        ),
        array(
            'relation' => 'AND',
            array( 'key' => 'bedrooms', 'value' => intval($bedrooms), 'compare' => '>=' ),
            array( 'key' => 'up_to_bedrooms', 'value' => intval($bedrooms), 'compare' => '<=' ),
            array( 'key' => 'up_to_bedrooms', 'value' => '', 'compare' => '!=' )
        )
    ),
    array(
        //another meta query
    )
);

What can I do?我能做什么?

bedrooms and up_to_bedrooms are key from custom fields.. I made the second one also mandatory to not have so complexed meta queries.. and it works fine right now as it is... bedrooms 和 up_to_bedrooms 是自定义字段的关键。我将第二个也强制设置为没有如此复杂的元查询。它现在工作正常......

here is the new query这是新查询

array(
    'relation' => 'AND',
    array(
        'relation' => 'AND',
        array( 'key' => 'status_0_bedrooms', 'value' => intval($bedrooms), 'compare' => '<=', 'type' => 'NUMERIC' ),
        array( 'key' => 'status_0_up_to_bedrooms', 'value' => intval($bedrooms), 'compare' => '>=', 'type' => 'NUMERIC' )
    ),
    array(
        //another meta query
    )
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM