Custom query filtered by meta_value that is an array?
-
Hi Everyone-
I just walked into the project close to its finish. They’re using custom fields where they should likely be using custom taxonomies, and I’m trying to work around that. I can’t really change their data structure at this point, so responses like “Use Custom Taxonomies,” while correct, are not apt.I’m trying to run a custom query that filters by meta_value. The value is an array though. Were it not an array, the following code would work.
$args = array( 'numberposts' => -1, 'post_type' => 'post', 'meta_query' => array ( array ( 'key' => 'my_key', 'value' => 'target_value', ) ) ); $new_query = new WP_Query( $args );
Since the key ‘my_key’ always has an array as its value, it will never match the queried ‘target_value’. How do I find the ‘target_value’ in the array? This is an array of strings by the way.
Any help would be really appreciated!!
Thanks. -John
- The topic ‘Custom query filtered by meta_value that is an array?’ is closed to new replies.