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

wp query - Meta_query on same meta key, with diffrenct values

programmeradmin3浏览0评论

i'm trying to get_users with the meta_query where i need to find users where either they don't have the meta key, or it is blank.

It seems like everywhere i look, i should be able to use the OR on the relation and then use the same meta key, but how ever i set it up, it does not work.

My code:

$ors[] = array(
   'key'   => 'death_date',
   'compare' => '=',
   'value' => '',
   'type' => 'NUMERIC'                    
);
$ors[] = array(
   'key'   => 'death_date',
   'compare' => 'NOT EXISTS'                    
);

$args = array(
   'meta_query' => array(
   'relation' => 'or',
   $ors,
));

$return = get_users($args);

Both of them work separately, but not together.

发布评论

评论列表(0)

  1. 暂无评论