Title: OderBy two Meta
Last modified: August 30, 2016

---

# OderBy two Meta

 *  [LucasGo](https://wordpress.org/support/users/lucasgo/)
 * (@lucasgo)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/oderby-two-meta/)
 * Hello everyone,
 * This is my first post here, I hoe this topic will be useful for many other people.
 * Here is my problem : I have posts with custom fields information, and I would
   like to sort them with 2 meta_value.
    Here is my **not working** code :
 *     ```
       <?php
       $idf_dept = array ('75', '77', '78', '91', '92', '93', '94', ' 95'); // the list "departements" I want OR don't want depending on the user choice
        $mapposts = new WP_Query( array('post_status' => 'publish',
       								'post_type' => 'post',
       								'category_name' => 'en_cours',
       								'meta_query' => array(
       														array(
       															'key'     => 'dept_nb_for_the_order',
       															'value'   => $idf_dept,
       															'compare' => $compare,
       															'orderby' => 'meta_value',
       															'order' => ASC
       														),
       														array(
       															'key'     => 'city_name_for_the_order',
       															'orderby' => 'meta_value',
       															'order' => ASC
       														)),
       								) );
       ?>
       ```
   
 * I’ve seen a lot of solutions, but not working for me… some are too old maybe.
 * I hope one of you have an answer, I’m getting mad on this one !!
    Thanks a lot
   🙂

The topic ‘OderBy two Meta’ is closed to new replies.

## Tags

 * [args](https://wordpress.org/support/topic-tag/args/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [order_by](https://wordpress.org/support/topic-tag/order_by/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 0 replies
 * 1 participant
 * Last reply from: [LucasGo](https://wordpress.org/support/users/lucasgo/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/oderby-two-meta/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
