Hi,
i need to show and filter posts on a widget by an ACF named ‘custom_date’.
This code works on a page but it doesn’t works on a widget.
$new_query = array(
‘post_type’ =>’post’,
‘meta_query’ => array(
‘key’ => ‘custom_date’,
‘value’ => date(‘Y-m-d H:i:s’),
‘type’ => ‘DATETIME’,
‘compare’=> ‘<‘)
);
SOLVED: It works by adding some other conditions to the query like that:
$new_query = array(
‘meta_key’=>’custom_date’,
‘orderby’=>’meta_value’,
‘order’=>’ASC’,
‘post_type’ =>’post’,
‘meta_query’ => array(
‘key’ => ‘custom_date’,
‘value’ => date(‘Y-m-d H:i:s’),
‘type’ => ‘DATETIME’,
‘compare’=> ‘<‘)
);