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
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
Share Improve this question edited Jul 22, 2014 at 9:05 kaiser 50.9k27 gold badges151 silver badges245 bronze badges asked Jul 21, 2014 at 18:11 Man_PatMan_Pat 11 bronze badge 4 |1 Answer
Reset to default 0It'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.
var_dump
$scoreboard
and see what the query looks like and if it's being cast as int. – Milo Commented Jul 21, 2014 at 19:04