Answer the question
In order to leave comments, you need to log in
Why doesn't the Wordpress&ACF filter work?
global $post;
if($_POST['marks']){
$marks = $_POST['marks'];
}else{
$args_marks = [
'taxonomy' => 'car_mark',
'hide_empty' => false,
];
$marks_term = get_terms( $args_marks );
$marks = [];
foreach($marks_term as $term){
$marks[] = $term->slug;
}
}
$status = $_POST['status'] ? $_POST['status'] : '';
$meta_q_status = [];
$paged = $_POST['paged'] ? $_POST['paged'] : 1;
$post_type = 'car';
$taxonomy_mark = 'car_mark';
if(!empty($status)){
foreach($status as $status_q){
$meta_q_status[] = [
'key' => 'position_car',
'value' => $status_q,
'compare' => 'LIKE',
];
}
}
$body_type = $_POST['body_type'] ? $_POST['body_type'] : '';
$meta_q_body_type = [];
if(!empty($body_type)){
foreach($body_type as $body_type_q){
$meta_q_body_type[] = [
'key' => 'position_car',
'value' => $body_type_q,
'compare' => 'LIKE',
];
}
}
$args = [
'post_type' => $post_type,
'post_status' => 'publish',
'tax_query' => [
[
'taxonomy' => $taxonomy_mark,
'field' => 'slug',
'terms' => array_values($marks),
],
],
'meta_query' =>
[
'relation' => 'AND',
$meta_q_status,
],
[
'relation' => 'AND',
$meta_q_body_type,
]
];
$cars = new WP_Query($args);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question