0

我需要构建 WP_Query,它将从满足两个条件的数据库返回数据,因为我使用 AND 作为关系,但返回的数据与我预期的不同。为了更清楚,我将在此处发布 WP_Query 参数。

Array(
[post_type] => Array
    (
        [0] => event
    )

[post_status] => publish
[paged] => 1
[posts_per_page] => 1000
[tax_query] => Array
    (
        [relation] => AND
        [1] => Array
            (
                [taxonomy] => event_dates
                [field] => slug
                [terms] => Array
                    (
                        [0] => thursday
                        [1] => exhibitions
                    )

            )

    )

)

有了这个论点,我想我会得到类型exibition 的事件,并且是在 Thursday

提前感谢您的帮助。

4

1 回答 1

1

AND是在错误的水平。WP_Query 参数应如下所示:

...
'tax_query' => array(
    array(
    'taxonomy' => 'event_dates',
    'field' => 'slug',
    'terms' => array('thursday', 'exhibitions'),
    'operator' => 'AND'
    )
)
...
于 2013-11-06T12:37:36.057 回答