I feel like my logic is off, but the short version is I have 2 custom fields spitting out unformated times for event-start-date and event-end-date. I don't want to show a post if the start-date is not equal or greater than today.

However, I want to show the post on the ending date. My issue is posts show up before and after the start day (this isn't mandatory but would be nice to figure out) but posts don't show up if the end date is the same as today. Is my logic in the code way off?

'meta_query'            => array(

        'relation'      => 'BETWEEN',
            'key'           => 'event-start-date',
            'value'     => time(),
            'compare'   => '<='
            'key'           => 'event-end-date',
            'value'     => time(),
            'compare'   => '>='

Thanks in advance.

  • What format do you save your dates as? – Howdy_McGee Jan 20 '16 at 17:17
  • 1
    BETWEEN is not a valid value for relation, it's either AND or OR. – Milo Jan 20 '16 at 17:21
  • @Howdy_McGee Unix Timestamps – Filipe Figueiredo Jan 20 '16 at 17:21
  • @Milo Put in the AND. Same result as BETWEEN anyway. – Filipe Figueiredo Jan 20 '16 at 17:23
  • Have you verified the value of time? Your local time and your server time are likely not the same. – Milo Jan 20 '16 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.