2

The problem is that users for whom votes_total doesn't exist are getting skipped. See below:

   $args = array(
       'meta_query' => array(
          'relation' => 'OR',
          array(
             'key' => 'votes_total',
             'compare' => '>',
             'value' => 0,
           ),
           array(
             'key' => 'votes_total',
             'compare' => 'NOT EXISTS',
             'value' => 0,
          ),
      ),
      'meta_key' => 'votes_total',
      'orderby' => 'meta_value_num',
      'order' => 'DESC'
   );
   $users = get_users($args);
1

Maybe this will answer your question:

(Note: Due to bug #23268, value was required for NOT EXISTS comparisons to work correctly prior to 3.9. You had to supply some string for the value parameter. An empty string or NULL will NOT work. However, any other string will do the trick and will NOT show up in your SQL when using NOT EXISTS. Need inspiration? How about 'bug #23268'.)

On https://codex.wordpress.org/Class_Reference/WP_Meta_Query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.