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!
$date = date('Y-m-d')
. – Cadu De Castro Alves2020-04-14
which confirms the formatY-m-d
described in the documentation. Have you tried to change the first line to$date = date('Y-m-d')
? – Cadu De Castro Alves