Title: Multiple meta_value sort help&#8230;
Last modified: August 22, 2016

---

# Multiple meta_value sort help…

 *  [blomster](https://wordpress.org/support/users/blomster/)
 * (@blomster)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/multiple-meta_value-sort-help/)
 * I’m trying to fix our team page with all our players but cant solve the problem
   with sorting with more than one argument. Cant figure out what i’m doing wrong…
 * Both arguments work fine by them selves, but just the first one works when I 
   use the code below. What i want is – first sort on category (A,B,C,D) and second
   sort on number. In other words – All the people on category A will be A12349 
   and not random like A39214….
 * Please se the template below with bold on the code thats failing.
 * <?php
    /* Template Name: Users */
 *  // Get all users order by category A,B,C,D,E and number
    **$users = get_users(
   array( ‘role’ => ”, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘category’, ‘order’
   => ‘ASC’, ‘meta_query’ => array( array( ‘orderby’ => ‘meta_value’, ‘meta_key’
   => ‘nummer’, ‘order’ => ‘ASC’, ))));
 *  // Remove user role by add role between ‘role goes here’
    foreach($allUsers 
   as $currentUser) { if(!in_array( ”, $currentUser->roles )) { $users[] = $currentUser;}}
 *  ?>
 * <?php get_header(); ?>
    <div class=”row”> <header class=”page-heading block-background
   block-inner”> <h3><?php wp_title(”); ?></h3> <div class=”minimize”></div> </header
   ><!– .page-heading –>
 * <div class=”main-content block-background column col12″>
    <div class=”block-inner”
   > <article class=”entry-post”> <header class=”entry-header”> <h2 class=”entry-
   title”><?php _e(”);?></h2>
 * <?php
 *  foreach($users as $user)
    { ?>
 * <div class=”author”>
    <div class=”comment-avatar”> <?php echo get_avatar( $user-
   >user_email, ’92’ ); ?> </div>
 * <div class=”authorInfo”>
 * <h1 class=”comment-author”><?php echo $user->display_name; ?> #<?php echo get_user_meta(
   $user->ID, ‘nummer’, true); ?></h1>
    <p class=”authorDescription”><?php echo 
   get_user_meta($user->ID, ‘position’, true); ?> | <?php echo get_user_meta($user-
   >ID, ‘land’, true); ?> cm | <?php echo get_user_meta($user->ID, ‘vikt’, true);?
   > kg | Födelseår: <?php echo get_user_meta($user->ID, ‘far’, true); ?></p>
 * </p>
    </div> </div>
 * <?php
    } ?> </section>
 * </header>
    </article>
 * </div><!– .block-inner –>
    </div><!– .main-content –>
 * </div>
    <?php get_footer(); ?>

The topic ‘Multiple meta_value sort help…’ is closed to new replies.

## Tags

 * [meta_value)](https://wordpress.org/support/topic-tag/meta_value/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)
 * [sorting](https://wordpress.org/support/topic-tag/sorting/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [blomster](https://wordpress.org/support/users/blomster/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/multiple-meta_value-sort-help/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
