Hi,
I've installed the new version of views which allows you to sort by post date. Which is great.
But I can't see a way to filter between two date ranges easily, I can filter between two YEARS but not Year, Month, Date.
One specific one that I need to do via url parameters is Financial year, which is June 31, to Jul 1 the following year. How can this be achieved with views?
URGENTLY need to figure this out.
Thanks
Also, if this could be updated via the existing ajax setup that would be ideal [rather than url param]
Hmmm, you've managed to make a date filter without the most basic necessity of a feature!
Simply needs to be able to filter between two dates, but it doesn't seem that views can do this even with the new version, what a let down!
Simply need the same as custom fields have - filter between to fields yyyy mm dd and yyyy mm dd.
Solved this with a custom query and url parameters. Shame views couldn't do it should have been easy.
For anyone else here's my code - it accepts 2 url parameters wpv-from-date and wpv-to-date, with the following date formats: MM/DD/YYYY
They can be added to a views page url like so:
?wpv-from-date=12/21/2012&wpv-to-date=9/6/2013
if($_GET["wpv-from-date"] && $_GET["wpv-to-date"]){
add_filter('wpv_filter_query', 'date_range', 99, 3 );
function date_range($query_args) {
$fromdate = $_GET["wpv-from-date"];
$todate = $_GET["wpv-to-date"];
$query_args['date_query'][] = array(
'after' => $fromdate,
'before' => $todate
);
return $query_args;
//var_dump($query_args);
}
}