Title: Sorting posts by meta value
Last modified: August 21, 2016

---

# Sorting posts by meta value

 *  [3dpc](https://wordpress.org/support/users/3dpc/)
 * (@3dpc)
 * [13 years ago](https://wordpress.org/support/topic/sorting-posts-by-meta-value/)
 * Currently I’m using this to sort posts by title:
    `<?php $posts = query_posts(
   $query_string . '&orderby=title&order=asc' ); ?>` I placed the code in index 
   before the loop starts. See the pastebin if you wanna see it all: [http://pastebin.com/MkbL3yZy](http://pastebin.com/MkbL3yZy)
 * But how do I sort posts by meta value? Simply changing title with meta_value 
   doesn’t work for me.
 * Any ideas? 🙂

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years ago](https://wordpress.org/support/topic/sorting-posts-by-meta-value/#post-3738741)
 * Did you also use the meta_key parameter in the query?
 *     ```
       <?php $posts = query_posts( $query_string . '&orderby=meta_value&meta_key=mymetakey&order=asc' ); ?>
       ```
   
 * Replace ‘mymetakey’ with the key of your Custom Field.
 * You may need to use orderby=meta_value_num if the values are numeric.

Viewing 1 replies (of 1 total)

The topic ‘Sorting posts by meta value’ is closed to new replies.

## Tags

 * [meta value](https://wordpress.org/support/topic-tag/meta-value/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/sorting-posts-by-meta-value/#post-3738741)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
