regex meta key for meta_query
-
Is it possible to use regex when providing meta_key?
I have unknown number of meta_keys to check; location-1, location-2, location-3 and so on. They can be few or dozens for different users.
I also tried using
'key' => array('location-1','location-2', 'location-3'),
and it gives following error.Warning: trim() expects parameter 1 to be string, array given in \wp-includes\class-wp-meta-query.php on line 584
$args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'location-/(\d+)$/', 'compare' => '=', ), array( 'key' => 'location-/(\d+)$/', 'compare' => 'NOT EXISTS' ) ), 'orderby' => 'meta_value_num', 'order' => 'DESC', );
Looking forward to your tips. Thanks
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘regex meta key for meta_query’ is closed to new replies.