So I have a complex list of ACF repeaters for ingredients, but have a save hook to store them all as one comma delimited text string in a custom field to help. My current "advanced" search passes ingredient searches as a meta query and works, but non-exact matches return nothing. Like if you search "pepper and paprika" it fails, but if you search "pepper" or "paprika" there are common posts (recipes).
Is there a way to make a meta query work like a normal query a little bit more?
My meta_query:
$args['meta_query'] = array(
array(
'key' => 'ingredient_list',
'value' => $search_query,
'compare' => 'LIKE',
)
);
Thank you for any help!
'value' => '"' . $search_query . '"'
help? Also meta queries can be named:$args['meta_query'] = [ 'query_a'=>['key' => 'ingredient_list' ... ], 'query_b'=>[ ... ] ]
, this can be useful when managing multiple meta queries & different combinations of and/or logic for the meta queries'value' => '%' . $search_query . '%'
? You could also take the string, useexplode(' ', $search_query)
to make an array of the words, remove any stop word (like "and"), then loop over them and add multiple meta queries with an or condition. Does that make sense?