Using a pre_get_posts filter to search a given string on all meta_values:
$query->set('meta_value', 'first string');
debug:
AND ( (CAST(wp_postmeta.meta_value AS CHAR) = 'first string') )
Works Ok 🙂 but how can I search on all meta_values for an array of strings?
For example. I need something like:
$query->set('meta_value', array('first string', 'second string'));
AND ( (CAST(wp_postmeta.meta_value AS CHAR) = 'first string') OR (CAST(wp_postmeta.meta_value AS CHAR) = 'second string') )
It is possible using $query->set(‘meta_value’… or something else?
Thanks in advance!
I made some fixes to this code as it doesn’t work anymore.
The following code will search the terms to be LIKE the title OR the content OR the meta_value :
and
Yes, I got it:
and: