Support

Account

Home Forums ACF PRO Meta Query Select ACF Not Returning Post For Current Date

Unread

Meta Query Select ACF Not Returning Post For Current Date

  • I am trying to get a post type to return based on a ACF Select (multiple) of days of the week, Mon-Sund. I set up a meta query with a relation of both the ACF Select key (show_days) and the current date. The var_dump is showing that the two arrays are comparing to each other, but still not showing the show (post type).

    <?php

    $date = date(‘l’);
    $shows = get_field(‘station_shows’, false, false);
    $query = new WP_Query ( array(
    ‘post_type’ => ‘shows’,
    ‘posts_per_page’ => 1,
    ‘post__in’ => $shows,
    ‘post_status’ => ‘publish’,
    ‘meta_query’ => array(
    ‘relation’ => ‘AND’,

    array (
    ‘key’ => ‘show_days’,
    ‘value’ => array(‘Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’,’Sunday’),
    ‘compare’ => ‘IN’,
    ),
    array (
    ‘key’ => ‘date’,
    ‘value’ => $date,
    ‘compare’ => ‘=’,
    ‘type’ => ‘DATE’,
    ),

    )));
    if ( $query->have_posts() ) { while( $query->have_posts() ) {
    $query->the_post();
    echo ‘<div class=”onAir”><h3>Currently On Air: ‘;
    the_title();
    if (get_field(‘dj’, $query->ID)) {
    $dj = get_field(‘dj’);
    echo ‘ w/ ‘;
    echo $dj;
    }
    echo ‘</h3></div>’;

    } wp_reset_postdata();
    }

    ?>

    I don’t know if the database meta value is not corresponding. I’ve even tried to unserialize() the array, but it still returns the same array value. Any help would be appreciated. Thank you!

Viewing 1 post (of 1 total)

The topic ‘Meta Query Select ACF Not Returning Post For Current Date’ is closed to new replies.