Home › Forums › General Issues › Use a JS array to search through meta_query › Reply To: Use a JS array to search through meta_query
No problem 🙂
I’m not an SQL expert but I thiiiiink you can’t do a IN search with the checkbox field as the value in the DB will be a serialized array.
I’m not sure how well this will play with your entire solution (and it’s not really performance-effective in the long run) but try if this works.
function product_search() {
$products = $_POST['products'];
$args = array(
'posts_per_page' => -1,
'post_type' => 'products',
);
$meta_query = array();
foreach( $products as $product ){
$meta_query[] = array(
'key' => 'products',
'value' => $product,
'compare' => 'LIKE'
),
}
$args['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.