最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Meta query with regular expression does not work

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论