So I just implemented for the first time the new WordPress ‘meta_query’ structure that was added to WordPress 3.1. I must say, it works swimmingly. Here’s my query:
-> To look up events that start after the current date and then order those events ascending by starting date:
$tday = date('Y-m-d H:i:s'); $args = array( 'post_type' => 'events', 'showposts' => 1, 'meta_query'=> array( array( 'key'=>'simplr_starts', 'value'=> $tday, 'compare' => '>' ) ), 'meta_key'=>'simplr_starts', 'orderby'=>'meta_value', 'order'=>'ASC' ); $events = new WP_query($args); // run the rest of the loop as usual.
Check out Scribu for more info.