Home Forums General Issues Query not running as expected Reply To: Query not running as expected

  • Ok, so it would appear this was due to the Return Format I had setup prior to the query being run.

    I’m still having problems understanding the compare, especially when the type is set to “DATE”, however.

    If I set the Return Format for the ACF to “Ymd” then it breaks the release date set on the individual films, whereas if I use the Custom value of “U” and run my query then it displays correctly (I then have to change the formatting later so that it displays in a “d/m/Y” format. For example, one film changes the set release date from 21/07/2028 to 23/08/1970?

        $dateToday = date('Ymd');
        $comingSoonFilms = new WP_Query(array(
            'post_type' => 'film',
            'posts_per_page' => -1,
            'order' => 'ASC',
            'meta_query' => array(
                'relation' => 'AND',
                    'key' => 'film_releasedate',
                    'value' => $dateToday,
                    'type' => 'DATE',
                    'compare' => '>',
                    'key' => 'film_active',
                    'value' => '1',