Tell us what you are trying to do?
Hello, we would like to restrict the view to the current day and the past 30 days of the current year on "new listings". Can you please guide us on how to achieve this?
What is the link to your site?
hidden link
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Philip,
Thank you for getting in touch.
The only way to do this is by using the view custom query filter to write a custom filter. Here is an example below.
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'] == 100) {
$query_args['date_query'] = array(
'column' => 'post_date',
'after' => '30 days ago',
);
}
return $query_args;
}
Now what you need to do is to replace the 100 with the ID of the view that you want the code to apply to.
This code will display all the posts that were published in the last 30 days.
Thanks,
Shane
My issue is resolved now. Thank you Shane!