Title: Ordering Posts
Last modified: August 20, 2016

---

# Ordering Posts

 *  [jarth3000](https://wordpress.org/support/users/jarth3000/)
 * (@jarth3000)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/ordering-posts-4/)
 * I’ve got a theme that I’m using and it’s throwing posts up on a slider on my 
   home page but I would like to order the way they show up. The code currently 
   in place is:
 *     ```
       <?php
       //OptionTree Stuff
       if ( function_exists( 'get_option_tree') ) {
       	$theme_options = get_option('option_tree');
       	$homeCategory = get_option_tree('home_category',$theme_options);
       	$homeNumber = get_option_tree('home_number',$theme_options);
       }
       ?>
   
       	<?php
       	$temp = $wp_query;
       	$wp_query= null;
       	$wp_query = new WP_Query();
       	$wp_query->query('cat='. $homeCategory .'&showposts='. $homeNumber .''.'&paged='.$paged);
       	while ($wp_query->have_posts()) : $wp_query->the_post();
       	?>
       ```
   
 * And the way I would like this to be ordered would be the following:
 * `orderby=meta_value&meta_key=event_date&order=ASC`
 * I’ve never used option tree before in obtaining information from some theme options,
   so I’m kind of confused on how I would integrate that ordering method with the
   other code. Any help is much appreciated, thanks!
 * Jarth

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/ordering-posts-4/#post-2392019)
 * You just need to add your arguments to the query string:
 * `$wp_query->query('cat='. $homeCategory .'&showposts='. $homeNumber .''.'&paged
   ='.$paged.'&orderby=meta_value&meta_key=event_date&order=ASC');`
 * Be sure your event_dates are stored with the year first, as in Y-m-d or Ymd format,
   or they won’t sort properly.
 *  Thread Starter [jarth3000](https://wordpress.org/support/users/jarth3000/)
 * (@jarth3000)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/ordering-posts-4/#post-2392028)
 * This didn’t work, just coming up with an error; I had already tried just placing
   at the end. Not sure what the deal is!
 *  Thread Starter [jarth3000](https://wordpress.org/support/users/jarth3000/)
 * (@jarth3000)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/ordering-posts-4/#post-2392029)
 * Never mind. I was being an idiot for about 2 seconds. Thanks vtxyzzy!

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

The topic ‘Ordering Posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [jarth3000](https://wordpress.org/support/users/jarth3000/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/ordering-posts-4/#post-2392029)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
