There’s no easy way to search serialized values in a meta query. If the list of values isn’t crazy long, potentially you could set up multiple meta queries:
1 2 3 4 5 6 7 8 9 10 11 12 13 | 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'system_power_supply', 'value' => 'single', 'compare' => 'LIKE', ), array( 'key' => 'system_power_supply', 'value' => 'redundant', 'compare' => 'LIKE', ) ) |
Or if you wanted to get super fancy, you could set it up dynamically:
1 2 3 4 5 6 7 8 9 | $values_to_search = array('single', 'redundant'); $meta_query = array('relation' => 'OR'); foreach ($values_to_search as $value) { $meta_query[] = array( 'key' => 'system_power_supply', 'value' => $value, 'compare' => 'LIKE', ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.