This plugin uses the below chunk of code to print the top 10 highscores.

But this doesn't get the list of top 10 scores sorted by meta_value in my WP install

$scoreboard = new WP_User_Query( array(
    'number'       => $top,
    'exclude'      => array( $exclude ),
    'orderby'      => 'meta_value',
    'order'        => 'DESC',
    'meta_key'     => 'wp2048_score',
    'meta_value'   => '0',
    'meta_compare' => '>',
) );

what could be wrong? I tried using meta_value_num too for orderby but still won't work. Am on wordpress 3.9.1

  • Please inent and add your code properly next time, it is unreadable. Also, contact the plugin author about this matter. This site doesn't offer support for third party plugins – Pieter Goosen Jul 21 '14 at 18:53
  • I believe this has nothing to do with the plugin. Just mentioned it as context. This is more a question on why meta_value_num is not working in this instance for orderby. Or more specifically why sorting meta_value as integer doesn't work, or how do I do it in a wp_query. Thanks for the formatting btw, will keep in mind next time. – Man_Pat Jul 21 '14 at 18:57
  • 1
    Then please be specific in your question. File an edit and add all relevant info to your question. Also add what you have done so far to solve your problem and where you are failing. As it stand, your question is off topic as you are asking support for a third party plugin. – Pieter Goosen Jul 21 '14 at 19:00
  • 1
    var_dump $scoreboard and see what the query looks like and if it's being cast as int. – Milo Jul 21 '14 at 19:04

It's not the plugin that is causing the issue it is the fact you are not querying the database correctly. It is not looking for integers your value is currently being stored as a string. To fix this you need to somehow change the value to a integer before it is passed to your array.

|improve this answer|||||

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.