My posts have meta keys _vote_user . user_id()
and value of (int) 1, 2 or 3.
I would like to return all posts with a meta KEY containing the string '_vote_user', i.e.: return all posts with meta vote for the current round but by any user.
$meta_query = [
[
'key' => '_vote_user_',
'value' => $atts['round'],
'compare' => 'LIKE'
]
];
As I understand it though, with the above code I'm querying the value for a LIKE value, not the key. How can I query the key? Maybe this illustrates better what I'm trying to achieve:
$meta_query = [
[
'key' => '_vote_user_%', // where '%' is any integer
'value' => $atts['round'],
'compare' => 'EXISTS'
]
];
EDIT
What if I were to first identify the IDs of the judges and query just those possible keys? So if my judges IDs were 2, 3 and 5 would the only way to query that be:
$meta_query = [
'relation' => 'OR',
[
'key' => '_vote_user_2',
'value' => $atts['round'],
],[
'key' => '_vote_user_3',
'value' => $atts['round'],
],[
'key' => '_vote_user_5',
'value' => $atts['round'],
]
];
It doesn't seem to be possible to submit an array of keys like you can for values.