I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm guessing i need to use the DATE or the DATETIME type for the meta query, but i don't know how to proceed:
if ($_GET['month']) {
$meta_query[] = array(
'key' => 'event_start_date',
'value' => $_GET['month']
);
}
$args = array(
'post_type' => 'event',
'paged' => $paged,
'posts_per_page' => -1,
'tax_query' => $cleanArray,
'meta_key' => 'event_start_date',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_query'=> $meta_query
);
$events = new WP_Query($args);
WP_Query
, you'll need a filter onposts_where
to query on just the month using MySQL's month function.