Hi there
I have a simple view of woocommerce orders, ordered by post date ascending, with a few filters to specify status etc.
I also need to filter the view to only show orders that were created/published yesterday.
After reading several support tickets on the subject, rather than using the view's date filter which has discrepancies when the year changes, I have tried the following in functions.php but... whatever I enter makes no difference to the output. The view only displays orders created today.
Here are the two I have tried so far that don't work. Note that on the first I tried with just one view and on the second I tried with all the views I need to use this filter with. If I change any of the elements nothing happens. The view continues to display today's orders.
add_filter( 'wpv_filter_query', 'get_past_one_month_posts', 10, 2);
function get_past_one_month_posts( $query_args ,$view_settings ) {
if (isset($view_settings['view_id']) && $view_settings['view_id'] == 33534) {
$query_args['date_query'] = array(
'column' => 'post_date',
'after' => '1 day ago',
);
}
return $query_args;
}
-----
OR
-----
add_filter( 'wpv_filter_query', 'limit_query_one_day', 10, 3 );
function limit_query_one_day($query_args, $view_setting, $view_id){
if (in_array($view_id, array( 33534, 33545, 33537, 33551, 33538, 33552 ))) {
$query_args['date_query'] = array(
array(
'before' => '0 day ago',
'after' => '1 day ago'
)
);
}
return $query_args;
}
Hoping someone can easily spot what the problem is...
Thanks in advance!
Rita