I have a custom post type named "performance". I have a custom post query that orders posts by a custom field value (order-date). Now I want to exclude posts that have order-dates that are in the past. I would think I could use the same "order-date" value to compare against todays date to determine if a post should be shown, but I can't find an example that works with the ordering. Everything I've tried breaks the ordering.
This seems to work!
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$today = date('Y-m-d');
query_posts(array(
'post_type' => 'performance',
'posts_per_page' => 5,
'caller_get_posts' => 5,
'paged' => $paged,
'meta_key' => 'order-date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'order-date',
'meta-value' => $value,
'value' => $today,
'compare' => '>=',
'type' => 'CHAR'
)
)
));
if (have_posts()) :
while (have_posts()) : the_post();
?>
Note that I defined "$today" and added it to the meta_array for comparison with the meta-value. The past-dated performance items disappeared from the list and everything looks like it should. Thanks to Brady for putting me on the right track.