Home › Forums › Front-end Issues › WP_Query checkbox array string error › Reply To: WP_Query checkbox array string error
Your problem is here, you are trying to set the “meta_query” argument twice.
'meta_query' => array(
array(
'key' => 'prix',
'type' => 'NUMERIC',
'value' => array($minprice, $maxprice),
'compare' => 'BETWEEN'
),
'meta_query' => $meta_query,
In this case “meta_query” will always be set to $meta_query and the part using “prix” will never happen. Your meta query also has other issues
<?php
$meta_query = array(
'relation' => 'AND'
);
if($_GET['minprice'] && !empty($_GET['minprice'])) {
$minprice = $_GET['minprice'];
} else {
$minprice = 0;
}
if($_GET['maxprice'] && !empty($_GET['maxprice'])) {
$maxprice = $_GET['maxprice'];
} else {
$maxprice = 999999;
}
$meta_query[] = array(
'key' => 'prix',
'type' => 'NUMERIC',
'value' => array($minprice, $maxprice),
'compare' => 'BETWEEN'
);
if($_GET['passion'] && !empty($_GET['passion'])) {
$passions = $_GET['passion'];
$nested_query = array(
'relation' => 'OR'
);
foreach((array) $passion as $passions){
$nested_query[] = array(
'key' => 'aimerparlapersonne',
'value' => $passions,
'compare' => 'LIKE',
);
}
$meta_query[] = $nested_query;
}
$args = array(
'post_type' => 'post',
'posts_per_page' => 20,
'tax_query' => array(
array(
'taxonomy' => $qobjet->taxonomy,
'field' => 'id',
'terms' => $qobjet->term_id,
),
),
'meta_query' => $meta_query
);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.