Title: orderby=ID for posts doesn&#039;t work
Last modified: August 20, 2016

---

# orderby=ID for posts doesn't work

 *  Resolved [thomas](https://wordpress.org/support/users/beloutte/)
 * (@beloutte)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/orderbyid-for-posts-doesnt-work/)
 * hi,
 * I try to order some posts by ID but it doesn’t seem to work…
 * here is my code :
 *     ```
       <?php if (have_posts()) : ?>
       <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("category_name=concerts&orderby=ID&paged=$paged"); ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="post-sum" id="post-<?php if ( get_post_meta($post->ID, 'date', true) ) { ?><?php echo get_post_meta($post->ID, "date", $single = true); ?><?php } ?>">
       ```
   
 * I used a custom field to have specific IDs (reverse date) to order post by concert
   date and not post publication date…
 * here is the page : [http://mascarel.eu/agenda/](http://mascarel.eu/agenda/)
 * what’s wrong with orderby=ID ???
    until now it’s been working but each new post
   appears on top, ignoring the ID…
 * please help !

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/orderbyid-for-posts-doesnt-work/#post-2367438)
 * Why not order by the date in the custom field “date”? If you have it formatted
   to yyyy-mm-dd. Then you can sort by using something like this:
 *     ```
       $args = array(
          'meta_key' => 'date',
          'orderby' => 'meta_value',
       );
       query_posts($args);
       ```
   
 *  Thread Starter [thomas](https://wordpress.org/support/users/beloutte/)
 * (@beloutte)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/orderbyid-for-posts-doesnt-work/#post-2367441)
 * many thanks !
    but how can I used this with the other query_posts values ?
 * like this maybe ? :
 *     ```
       <?php if (have_posts()) : ?>
       <?php
           $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
           $args = array(
              'meta_key' => 'date',
              'orderby' => 'meta_value',
              'category_name'  => 'concerts',
              'paged' => '$paged'
           );
       query_posts($args); ?>
       ```
   
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/orderbyid-for-posts-doesnt-work/#post-2367447)
 * > like this maybe?
 * Yes exactly like that.
 * New posts always get a higher ID than all the other posts so ordering it by “
   ID” is no option.
 *  Thread Starter [thomas](https://wordpress.org/support/users/beloutte/)
 * (@beloutte)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/orderbyid-for-posts-doesnt-work/#post-2367450)
 * ok I’ll try this in a couple of minutes
 * but with my custom field as post ID it should have worked ? no ?
 * edit: It works ! thanks a lot !
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/orderbyid-for-posts-doesnt-work/#post-2367479)
 * Glad you got it resolved.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘orderby=ID for posts doesn't work’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/orderbyid-for-posts-doesnt-work/#post-2367479)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
