WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to display a custom post type if the current date is between the start and end custom meta field dates. Here is my code so far, it seems to just be ignoring the query and displaying all 3 of the posts, I have probably made a mistake as I have been been working on it for 3 days straight now, any help would be greatly appreciated. I am not even sure if this can work, I have successfully been able to show the posts that are after the end date and posts before the start date but can seem to get the ones that are between the two dates.

    $todaysDate = date('Y/m/d');
$args = array(
'post_type' => 'exhibitions',
'orderby' => 'meta_value',
'post_status' => 'publish',
'meta_query' => array(

    array('key' => 'start_date', 'value' => $todaysDate, 'compare' => '>=', 'type' => 'DATE'),
    array('key' => 'end_date', 'value' => $todaysDate, 'compare' => '<=', 'type' => 'DATE') 
) ); 
share|improve this question

Untested solution, just a thought really, but what if 'value' => 'NOW()' so that you avoid having to pass the date, which seems like it's probably the issue?


Alternate solution: Your SQL date format is wrong. It should be $todaysDate = date( 'Y-m-d' ), that should also be the format it is stored in if the row format is DATE or TIME

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.