wordpress税务查询和元查询一起使用
我尝试使用tax_查询和meta_查询来获得帖子。我在网上读到的东西不起作用 这是一个CPT和职位 理想情况下,我想返回的是所有帖子,只有即将到来的事件 目前,我似乎只能返回其中一个或另一个。使用下面的代码,我只返回即将到来的CPT 你知道我哪里会出错吗wordpress税务查询和元查询一起使用,wordpress,meta-query,Wordpress,Meta Query,我尝试使用tax_查询和meta_查询来获得帖子。我在网上读到的东西不起作用 这是一个CPT和职位 理想情况下,我想返回的是所有帖子,只有即将到来的事件 目前,我似乎只能返回其中一个或另一个。使用下面的代码,我只返回即将到来的CPT 你知道我哪里会出错吗 // Get the application taxonomies $terms = get_the_terms( $post->ID, 'cpt_taxonomy' ); if( empty( $term
// Get the application taxonomies
$terms = get_the_terms( $post->ID, 'cpt_taxonomy' );
if( empty( $terms ) ) $terms = array();
$term_ids = wp_list_pluck( $terms, 'term_id' );
// Get todays date
$today = date("Ymd");
$news = get_posts([
'post_type' => array(
'post',
'tribe_events'
),
'posts_per_page' => 12,
'post__not_in' => array( get_the_ID() ),
'orderby' => 'date',
'order' => 'desc',
'meta_key' => '_EventStartDate',
//'orderby' => 'meta_value',
//'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_EventStartDate',
'value' => $today,
'compare' => '>=',
'type' => 'DATE'
)
),
'tax_query' => array(
array(
'taxonomy' => 'cpt_taxonomy',
'field' => 'term_id',
'terms' => $term_ids,
//'operator' => 'IN'
)
)
]);
我也有同样的问题,我发誓什么都不管用。我最终失去了理智,求助于$wpdb,自己写下了这个愚蠢的查询。如果知道有帮助的话。。。部落活动。。。我们都使用同一个插件。也许这就是它不起作用的原因。