I am trying to get a meta query with a regular expression to work.
I have a custom post type with a custom field "participant-id".
The custom field stores a comma-delimited string of user IDs, like: 56,123,99,199
My query is:
'meta_query' => array(
array(
'key' => 'event-id',
'value' => $eventID,
'compare' => '=',
),
array(
'key' => 'participant-id',
'value' => "(?<!(\d|\w))99(?!(\d|\w))",
'compare' => "REGEXP",
)
)
According to the WP Codex and all other examples I have found here on the topic, this should work, but it doesn't. The right values are not returned, meaning that in this case, the post that has a custom field with a participant id of 99 in it is not found.
I am trying to get this regular expression to work because before I had a LIKE compare operator and it would consider 99 and 199 to be the same, giving false results.
Any suggestions?
Thanks.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745157657a4614220.html
评论列表(0条)