Tell us what you are trying to do?
I want to hide posts from a View that are 60 days old (based of publish date). How can I do this?
Hi,
Thank you for contacting us and I'd be happy to assist.
To filter the view's results, where the published date falls within the last 60 days, you can use the 'wpv_filter_query', like this:
add_filter( 'wpv_filter_query', 'custom_date_filter_func', 1000 , 3 );
function custom_date_filter_func( $query_args, $view_settings ) {
// process if specific view
if ( ( isset($view_settings['view_id']) && $view_settings['view_id'] == 1234) ) {
$query_args['date_query'] = array(
array(
'after' => '-60 days',
'column' => 'post_date',
)
);
}
return $query_args;
}
Note: you'll replace '1234' with your actual view's ID.
Related links:
https://developer.wordpress.org/reference/classes/wp_query/#date-parameters
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar