Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

andy999 on "Sort users by meta_value_num"

$
0
0

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 all articles
Browse latest Browse all 8245

Trending Articles