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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.