Title: query_posts ordering issue
Last modified: August 20, 2016

---

# query_posts ordering issue

 *  Resolved [jason.wintermeyer](https://wordpress.org/support/users/jasonwintermeyer/)
 * (@jasonwintermeyer)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/)
 * Pulling my hair out trying to get these thumbnails to display in the latest order‘
   newest first’ – Have tried various different permutations but still the thumbnails
   display as ‘oldest first’.
 *     ```
       <div class="container">
       <?php if ( have_posts() ) : ?>
       <?php query_posts(array( 'order'=>'desc', 'orderby'=>'post_date','category__and' => (22), 'showposts' => -1 )); $c = 0;  ?>
       <?php while ( have_posts() ) : the_post(); $c++; ?>
       <div class="four columns"> <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" style="display:block;">
         <?php
       if(has_post_thumbnail()) {
       	the_post_thumbnail('medium');
       } else {
       	echo '<img src="'.get_bloginfo("template_url").'/images/img-default.png" width="220" height="147" />';
       }
       ?>
         </a> <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>">
         <?php the_title(); ?>
         </a>
         <h6>
           <?php the_field('job_url'); ?>
         </h6>
       </div>
       <?php if( $c == 4) echo '</div><!--container end--><div class="container"><!--container start-->'; elseif ($c == 8) echo '</div><!--container end-->';?>
       <?php if( $c == 8) echo '<div class="container"><!--container start-->'; elseif ($c == 12) echo '</div><!--container end-->';?>
       <?php if( $c == 12) echo '<div class="container"><!--container start-->'; elseif ($c == 16) echo '</div><!--container end-->';?>
       <?php endwhile; endif; ?>
       ```
   

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992853)
 * Try just using:
 * `<?php query_posts(array( 'category__and' => (22), 'posts_per_page' => -1 ));
   $c = 0; ?>`
 *  Thread Starter [jason.wintermeyer](https://wordpress.org/support/users/jasonwintermeyer/)
 * (@jasonwintermeyer)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992874)
 * Still no joy i’m afraid I have tried doing this aswell
 * `<?php query_posts('cat=-1&orderby=date&order=ASC&showposts=1'); ?>`
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992875)
 * Posts are listed in date order (newest first) by default then using query_posts().
   If that’s not happening, then something else on the page is interfering with 
   the query. Another Loop perhaps?
 *  Thread Starter [jason.wintermeyer](https://wordpress.org/support/users/jasonwintermeyer/)
 * (@jasonwintermeyer)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992879)
 * no other loops on the page, thats why im getting so frustrated and am also using
   the latest version of WP – Really strange as the order does keep changing intermittently
   although never into the latest post order i require….back to the drawing board
   perhaps…maybe i will look at using get_posts instead
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992883)
 * Are you amending the query for the main Loop? Or this for a secondary Loop?
 *  Thread Starter [jason.wintermeyer](https://wordpress.org/support/users/jasonwintermeyer/)
 * (@jasonwintermeyer)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992884)
 * ive nailed it…had a conflicting plugin installed called ‘Custom Page Order’ this
   was affecting the order of the posts. THanks for your help 🙂
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992885)
 * Glad to hear that you managed to sort it 🙂
 *  Thread Starter [jason.wintermeyer](https://wordpress.org/support/users/jasonwintermeyer/)
 * (@jasonwintermeyer)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992886)
 * feel very stupid…schoolboy error!

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

The topic ‘query_posts ordering issue’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 2 participants
 * Last reply from: [jason.wintermeyer](https://wordpress.org/support/users/jasonwintermeyer/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/query_posts-ordering-issue/#post-2992886)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
