Sort users by meta_value_num
-
Been trying some things to output some users and sort by a meta_value_num, but nothing I try works and I can’t find anything online about it.
This one’s a real challenge.
<?php $args = array( 'orderby' => 'meta_value_num', 'meta_key ' => 'rank', 'order' => 'DESC', ); // The Query $user_query = new WP_User_Query( $args ); // User Loop if ( ! empty( $user_query->results ) ) { foreach ( $user_query->results as $user ) { echo '<p>' . $user->display_name . '</p>'; } } else { echo 'No users found.'; } ?>
I can get the meta value for each author on author.php easily enough but I can’t get users to sort by the same meta value.
[Moderator Note: No bumping. If it’s that urgent, consider hiring someone instead.]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sort users by meta_value_num’ is closed to new replies.