Sunday, November 18, 2012

meta_query with comparison

Display posts of type 'my_custom_post_type', ordered by 'training_date', and filtered
  <?php
$todaysDate = date( 'd-m-Y' );
$args = array(
'post_type' => 'training',
'meta_key' => 'training_date',
'orderby' => 'training_date',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'training_date',
'value' => $todaysDate,
'compare' => '>=',
))

);
$query = new WP_Query($args);

No comments:

Post a Comment