谢谢你的帮助!以下是我最终得到的结果:
if(is_page(199)) {
// The Query
$event_args = array (
\'post_type\' => \'tribe_events\',
\'posts_per_page\' => 1,
\'suppress_filters\' => true,
\'tax_query\' => array (
\'relation\' => \'AND\',
array (
\'taxonomy\' => \'tribe_events_cat\',
\'field\' => \'slug\',
\'terms\' => \'streamteam\',
),
array (
\'taxonomy\' => \'tribe_events_cat\',
\'field\' => \'slug\',
\'terms\' => \'featured\',
),
),
\'meta_query\' => array(
array(
\'key\' => \'_EventStartDate\',
\'value\' => date("Y-m-d"),
\'compare\' => \'>=\',
\'type\' => \'DATE\',
),
),
\'meta_key\' => \'_EventStartDate\',
\'order\' => \'ASC\'
);
} else {
// The Query
$event_args = array (
\'post_type\' => \'tribe_events\',
\'posts_per_page\' => 1,
\'suppress_filters\' => true,
\'tax_query\' => array (
array (
\'taxonomy\' => \'tribe_events_cat\',
\'field\' => \'slug\',
\'terms\' => \'featured\',
),
),
\'meta_query\' => array(
array(
\'key\' => \'_EventStartDate\',
\'value\' => date("Y-m-d"),
\'compare\' => \'>=\',
\'type\' => \'DATE\',
),
),
\'meta_key\' => \'_EventStartDate\',
\'order\' => \'ASC\'
);
}
$event_query = new WP_Query( $event_args );
// The Loop
if ( $event_query->have_posts() ) {
while ( $event_query->have_posts() ) {
$event_query->the_post();
?>
POST CONTENT HERE
<?php
}
}
而不是使用数组(
$tribe_events_cat
) 对于我的
terms
子查询,我必须使用两个单项
terms
子查询,打开我的
tax_query
进入并请求中的职位
featured
和
streamteam
.
还有,我不得不补充\'suppress_filters\' => true,
到每个args数组,以修复在我的查询之外发生的影响我的结果的一些奇怪的过滤问题。