admin管理员组

文章数量:1406177

The intention is to search for customers who do not have coupon X or do not have any coupon.

    $query = array (
        'post_type'      => 'clients',
        'meta_query'=> array(
            'relation' => 'OR',
            array(
               'key' => 'cupom',
               'value' => $idCupom,
               'compare' => '!=',
        ), array(
              'key' => 'cupom',
              'compare' => 'NOT EXISTS',
              'value' => '',
        )),
        'posts_per_page' => -1,
    );

I am doing according to other answers I found on the web, but the query returns wrong when it finds a post that has a meta_value different from the one searched.

本文标签: customizationQuerying posts that don39t have a certain key value or don39t have the key