Title: wp_query Select &amp; sort by multiple custom fields
Last modified: August 20, 2016

---

# wp_query Select & sort by multiple custom fields

 *  [FixMiller](https://wordpress.org/support/users/fixmiller/)
 * (@fixmiller)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/wp_query-select-sort-by-multiple-custom-fields/)
 * I have multiple post types that all have same two custom fields : featured and
   fixed, booth Boolean.
    I’m trying to get all the post that have the featured 
   enabled and sort them so all the ones that have fixed true will be first in the
   query.
 * this is what i have so far. it works for selecting the featured ones, but i can’t
   get the sorting part to work.
 *     ```
       $args = array(
       'post_type'=>array('panels', 'guests', 'amtv'),
       'meta_query' => array(
       array ('key' => 'featured',
       'value' => 1,
       'compare' => '=',
       'type' => 'CHAR'
       ),
       array ('key' => 'fixed'
       'order' => 'ASC',
       'orderby' => 'value'
       )
       )
       );
       query_posts($args);
       ```
   
 * Any help would be appreciated 🙂

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/wp_query-select-sort-by-multiple-custom-fields/#post-2713472)
 * If you change the fixed field to string or integer instead of boolean, then it
   will sort. This may not be practical for other reasons, but it’s an idea.

Viewing 1 replies (of 1 total)

The topic ‘wp_query Select & sort by multiple custom fields’ is closed to new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/wp_query-select-sort-by-multiple-custom-fields/#post-2713472)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
