wordpress query_posts中的多个数组查询

时间:2014-11-30 16:42:36

标签: php wordpress

我已经创建了多个数组查询,如下所示:

Array
(
    [post_type] => product
    [posts_per_page] => -1
    [meta_query] => Array
        (
            [relation] => AND
            [0] => Array
                (
                    [0] => Array
                        (
                            [key] => kind_of
                            [value] => text_of_kind
                            [compare] => LIKE
                        )

                    [1] => Array
                        (
                            [key] => production_type
                            [value] => 'Production sample name'
                            [type] => char
                            [compare] => LIKE
                        )
                )
        )
)

...但是在循环中我得到两个结果(如[relation] => OR)有什么问题?

1 个答案:

答案 0 :(得分:0)

元查询不应嵌套在数组中。

$query_args = array(
    'relation' => 'AND',
    array( 'key' => 'foo' ),
    array( 'key' => 'bar' )
);

检查食典委中的WP_Meta_Query