我可以在你的代码中看到你在元键参数上犯了错误。必须使用下划线而不是连字符符号。以下是更正的代码:
$args = array(
\'number\' => 5 ,
\'meta_key\' => \'post_count\',
\'meta_value\' => 10,
\'meta_compare\' => \'>\',
\'orderby\' => \'rand\'
);
$user_query = new WP_User_Query( $args );
if ( ! empty( $user_query->get_results() ) ) {
foreach ( $user_query->get_results() as $user ) {
echo $user->display_name ;
}
} else {
echo \'No users found.\';
}
希望这能奏效!