我想从两个不同的自定义帖子类型中检索结果。我查询了tax_query
,meta_query
和另一个meta_query
但是没有结果。应该有一个结果。
$args = array(
'post_type' => 'listings',
's' => get_query_var( 's' ),
'paged' => $paged,
'meta_query' => array(
'relation' => 'OR',
),
'tax_query' => array(
'relation' => 'OR',
),
'posts_per_page' => 15,
);
if(isset($_GET['city']) && !empty($_GET['city'])){
$args['tax_query'][] = array(
array(
'taxonomy' => 'city',
'field' => 'slug',
'terms' => $selected_city,
'relation' => 'OR',
),
);
}
if(isset($_GET['cuisine'])){
$args['tax_query'][] = array(
array(
'taxonomy' => 'cuisine',
'field' => 'slug',
'terms' => $selected_cuisine,
'relation' => 'OR',
),
);
}
if(isset($_GET['st'])){
$args['meta_query'][] = array(
array(
'key' => 'restaurent_location',
'value' => $location,
'compare' => 'LIKE',
),
);
}
if(isset($_GET['has_takeaway'])){
$args['meta_query'][] = array(
array(
'key' => 'has_resturent_takeaway',
'value' => $takeaway,
'compare' => '=',
),
);
}
$arg2 = array(
'post_type' => 'reviews',
'meta_query' => array(
'relation' => 'OR',
),
);
if(isset($_GET['rating_range'])){
$args2['meta_query'][] = array(
array(
'key' => 'review_rating',
'value' => array( $rating_range[0], $rating_range[1] ),
'compare' => 'BETWEEN',
),
);
}
$query = new WP_Query( array_merge($args, $args2) );
答案 0 :(得分:0)
get_query_var('s')应该只是$ s。现在它不是在寻找任何东西。