im trying to get all posts that has a custom field which is in an array of dates that i create.
the field is a color picker
<?php
$date_start = date("Y/m/d");
$end_date = date("Y/m/d", strtotime("+6 day", strtotime($date_start)));
$dates = array();
while (strtotime($date_start) <= strtotime($end_date)) {
array_push($dates, $date_start);
$date_start = date("Y/m/d", strtotime("+1 day", strtotime($date_start)));
}
$formatted_dates = array();
foreach($dates as $date) {
array_push($formatted_dates, date_i18n("d/m/Y", strtotime($date)));
}
var_dump($formatted_dates);
$the_query = new WP_Query(array(
'post_type' => 'event',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'event_date',
'value' => $formatted_dates,
'compare' => 'IN',
),
),
));
?>
update: this code works if the field is text field and not date picker